Virtual and Pure Virtual functions.
-
Hello Friends, I have a doubt. See the following code. class Example { public: virtual void show() { cout<<"Base class Show"; } virtual void display() = 0; virtual void disp() = 0; }; When the object of its derived class object is created. In the V-Table, what will be the order of the virtual function. Whether the normal virtual function will be placed first and then the pure virtual function or else, it depends upon the order used in declaring them in the class. Thanks in advance. Neelesh K J Jain.
-
Hello Friends, I have a doubt. See the following code. class Example { public: virtual void show() { cout<<"Base class Show"; } virtual void display() = 0; virtual void disp() = 0; }; When the object of its derived class object is created. In the V-Table, what will be the order of the virtual function. Whether the normal virtual function will be placed first and then the pure virtual function or else, it depends upon the order used in declaring them in the class. Thanks in advance. Neelesh K J Jain.
-
Hello Friends, I have a doubt. See the following code. class Example { public: virtual void show() { cout<<"Base class Show"; } virtual void display() = 0; virtual void disp() = 0; }; When the object of its derived class object is created. In the V-Table, what will be the order of the virtual function. Whether the normal virtual function will be placed first and then the pure virtual function or else, it depends upon the order used in declaring them in the class. Thanks in advance. Neelesh K J Jain.
It usually is in the same order as you declare, but it's not required to by the C++ standard. In fact, the standard doesn't talk about object layout at all. AFAIK, COM relies on the ordering of functions in the vtable, so I guess the VC++ compiler must put them in the same order as you declare. Regards Senthil _____________________________ My Blog | My Articles | WinMacro