Advertisements
Advertisements
प्रश्न
Write any six rules for virtual functions.
दीर्घउत्तर
Advertisements
उत्तर
When virtual functions are used to implement late binding, certain basic rules must be followed to meet compiler requirements:
- Virtual functions must belong to a class.
- They cannot be declared as static members.
- Virtual functions are invoked using object pointers.
- A virtual function can also be declared as a friend of another class.
- A virtual function declared in a base class must have a definition, even if it is not used directly.
- The function prototypes of the virtual function in the base class and all derived classes must be exactly the same. If the prototypes differ, C++ treats them as overloaded functions, not virtual functions.
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
2021-2022 (March) Set 1
