Technical Discussion :: C++
Home > Technical Interview Q&A > C++ > Discussion
101 / 187
What are the rules of virtual function?
Answer:
1. Virtual functions must be members of some class.
2. They cannot be static members.
3. They are accessed by using object pointers.
4. A virtual function can be a friend of another class.
5. We cannot have virtual constructors but we can have virtual destructors.
6. If a virtual function is defined in the base class. It need not be necessarily redefined in the derived class.
Asked In ::
Madhuri D
23 Feb, 2019 5:07 AM
1. Virtual functions must be members of some class.
2. They cannot be static members.
3. They are accessed by using object pointers.
4. A virtual function can be a friend of another class.
5. We cannot have virtual constructors but we can have virtual destructors.
6. If a virtual function is defined in the base class. It need not be necessarily redefined in the derived class.
2. They cannot be static members.
3. They are accessed by using object pointers.
4. A virtual function can be a friend of another class.
5. We cannot have virtual constructors but we can have virtual destructors.
6. If a virtual function is defined in the base class. It need not be necessarily redefined in the derived class.