virtual or pure virtual
Hi, can anyone tell the rules of declaring a function virtual or pure virtual?
The derived class will need to declare the inherited function as virtual if the same function is pure virtual in the base class. Is this right?
How about when writing an abstract base class? I'm confused about pure virtual and virtual here.
You use a PURE virtual function when you only want to specify an interface and do not need a default implementation of that function.Any class that has a pure virtual function is an ADT. You cannot instantiate objects of this type yet you may use pointers or references to it. This makes it a class that is purely to be inherited from.Any class derived from this class that does not provide an implementation for this function automatically becomes an ADT.
You use an IMPURE virtual function when you want to specify an interface and also a default implementation. This way you can instantiate objects of the class.