1. A class member function can be declared to be pure virtual by just specifying the keyword „virtual‟ in front and putting „=0‟ at the end of the function declaration
2. Pure virtual function itself do nothing but acts as a prototype in the base class and gives the responsibility to a derived class to define this function.
3. As pure virtual functions are not defined in the base class thus a base class can not have its direct instances or objects that means a class with pure virtual function acts a n abstract class that cannot be instantiated but its concrete derived classes can be.
4. We cannot have objects of the class having pure virtual function but we can have pointers to it that can in turn hold the reference of its concrete derived classes.
5. Pure virtual functions also implements run time polymorphism as the normal virtual functions do as binding of functions to the appropriate objects here is also delayed up to the run time, that means which function is to invoke is decided at the run time.
6. Pure virtual functions are meant to be overridden.
7. Only the functions that are members of some class can be declared as pure virtual that means we cannot declare regular functions or friend functions as pure virtual.
8. The corresponding functions in the derived class must agree be compatible with the pure virtual function‟s name and signature that means both must have same name and signature.
9. For abstract class, pure virtual function is must.
10. The pure virtual functions in an abstract base class are never implemented. Because no objects of that type are ever created, there is no reason to provide implementations, and the ADT (Abstract Data Type) works purely as the definition of an interface to objects which derive from it.
11. It is possible, however, to provide an implementation to a pure virtual function. The function can then be called by objects derived from the ADT, perhaps to provide common functionality to all the overridden functions.
0 टिप्पणियाँ:
Post a Comment