I know that the normal member function of a template class will be instantiated whenever it is used for the first time. But this cannot be done for the virtual member function as it can be accessed through a base class pointer. Does this mean that virtual member functions will be instantiated as soon as the template class is instantiated? If not, when?
14.7.1/9
in C++03:
An implementation shall not implicitly instantiate a function template, a member template, a non-virtual member function, a member class or a static data member of a class template that does not require instantiation. It is unspecified whether or not an implementation implicitly instantiates a virtual member function of a class template if the virtual member function would not otherwise be instantiated.
It is implementation defined.
But usually when a template class is instantiated all member for the new class type are generated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With