What do virtual inline function mean?
-
If declare a virtual function as inline what is the effect on the code. Vikas Amin Embin Technology Bombay
-
If declare a virtual function as inline what is the effect on the code. Vikas Amin Embin Technology Bombay
it will try to inline the function if it provides an implementation of the function that is actually called...
TOXCCT >>> GEII power
[toxcct][VisualCalc 2.20][VCalc 3.0 soon...] -
it will try to inline the function if it provides an implementation of the function that is actually called...
TOXCCT >>> GEII power
[toxcct][VisualCalc 2.20][VCalc 3.0 soon...]Actually, it won't. "virtual inline" makes no sense and the inline specifier will be ignored. Virtual functions let an object decide at runtime which particular implementation of a method should be invoked. If you have a pointer to the base object and call a virtual method, there is no way to know at compile time what type of object will be present at the actual time of the call. Hence, the compiler won't be able to figure out which implementation of the function to compile inline.
The two most common elements in the universe are Hydrogen and stupidity. - Harlan Ellison Awasu 2.2 [^]: A free RSS/Atom feed reader with support for Code Project.
-
Actually, it won't. "virtual inline" makes no sense and the inline specifier will be ignored. Virtual functions let an object decide at runtime which particular implementation of a method should be invoked. If you have a pointer to the base object and call a virtual method, there is no way to know at compile time what type of object will be present at the actual time of the call. Hence, the compiler won't be able to figure out which implementation of the function to compile inline.
The two most common elements in the universe are Hydrogen and stupidity. - Harlan Ellison Awasu 2.2 [^]: A free RSS/Atom feed reader with support for Code Project.
exactly!!
-Prakash
-
Actually, it won't. "virtual inline" makes no sense and the inline specifier will be ignored. Virtual functions let an object decide at runtime which particular implementation of a method should be invoked. If you have a pointer to the base object and call a virtual method, there is no way to know at compile time what type of object will be present at the actual time of the call. Hence, the compiler won't be able to figure out which implementation of the function to compile inline.
The two most common elements in the universe are Hydrogen and stupidity. - Harlan Ellison Awasu 2.2 [^]: A free RSS/Atom feed reader with support for Code Project.
Taka Muraoka wrote:
Virtual functions let an object decide at runtime which particular implementation of a method should be invoked. If you have a pointer to the base object and call a virtual method, there is no way to know at compile time what type of object will be present at the actual time of the call. Hence, the compiler won't be able to figure out which implementation of the function to compile inline
This is of course, correct. However, if you use an object of the class in a non-polymorphic manner (say, create it on the stack), the compiler can figure out which object is used and inline the function. Therefore, "virtual inline" actually makes sense, and will not be ignored ;)
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.