Link to home
Start Free TrialLog in
Avatar of vimalalex
vimalalex

asked on

COM/DCOM

Hi experts,
           
                        what is the use of ATL_NO_VTABLE macro what it actually does. Is it disable the vtable of the base classes or the current class.

Regards,
Vimal.
Avatar of Paul Jackson
Paul Jackson
Flag of United Kingdom of Great Britain and Northern Ireland image

According to MSDN (http://msdn.microsoft.com/en-us/library/w4baz6ss(v=VS.80).aspx), ATL_NO_VTABLE expands to declspec(novtable), which causes the linker to eliminate the vtable (and all the functions it points to), and should only ever be applied to an abstract base class.

It disables the vtable of the class to which the modifier is applied, but you should not apply it to your most-derived (or any creatable) class.
Avatar of vimalalex
vimalalex

ASKER

Hi tgerbert,

                       By eliminating vtable so we cant use function overridding right if we have normal virtual function in base class.What is the necessary for eliminating vtable of base class.

regards,
vimal.
ASKER CERTIFIED SOLUTION
Avatar of Deepu Abraham
Deepu Abraham
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi DeepuAbrahamK,

                       Thanks for your excellent reply.
Regards,
Vimal.
MSDN also says "You must use ATL_NO_VTABLE, and consequently declspec(novtable), with only base classes that are not directly creatable", so you shouldn't apply it to Animal in the above example because Animal doesn't contain any pure virtual functions (i.e. it can be directly created).

The point is that since you can't create an abstract base class anyway, there's no need for it to have a vtable so it can be removed to reduce code size.