is it correct to say that to take advantage of polymorphism at runtime, all of the base class functions that will be overriden must be virtual. If they are not, then you are really utilizing polymorphism at compile time?
Do you guys use virtual sparingly, or frequently?

>is it correct to say that to take advantage of polymorphism at
>runtime, all of the base class functions that will be overriden must be virtual.
Virtual member functions are how C++ supports run-time polymorphism, so it is correct to say that to take advantage of run-time polymorphism, you need to have virtual member functions for those member functions you wish to be polymorphic.[1]

>If they are not, then you are really utilizing polymorphism at compile time?
It's generally more accurate to say that virtual member functions allow run-time polymorphism and templates allow compile time polymorphism. If you try to use run-time polymorphism but failed to define any virtual member functions, the result simply won't be polymorphic at all.

>Do you guys use virtual sparingly, or frequently?
I use inheritance very rarely, but when I do it's nearly always to implement an abstract interface, which results in at least one virtual member function.

[1] Narue uses big words and long sentences. Deal with it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.