HSC Science (Computer Science) 12th Board ExamMaharashtra State Board

View all notifications

Write Any Eight Basic Rules for Virtual Function that Satisfies the Compiler Requirements - HSC Science (Computer Science) 12th Board Exam - Computer Science 1

Create free account

      Forgot password?


Write any eight basic rules for the virtual function that satisfies the compiler requirements


Rules for Virtual Functions

1) The 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) A virtual function in a base class must be defined, even though it may not be used.

6) The prototypes of the base class version of a virtual function and all the derived class versions must be identical. If two functions with the same name have different prototypes, C++ considers them as overloaded functions, and the virtual function mechanism is ignored.

7) We cannot have virtual constructors, but we can have virtual destructors.

8) While a base pointer can point to any type of the derived object, the reverse is not true. That is to say, we cannot use a pointer to a derived class to access an object of the base type.

9) When a base pointer points to a derived class, incrementing or decrementing it will not make it to point to the next object of the derived class. It is incremented or decremented only relative to its base type. Therefore, we should not use this method to move the pointer to the next object.

10) If a virtual function is defined in the base class, it need not be necessarily redefined in the derived class. In such cases, calls will invoke the base function.

  Is there an error in this question or solution?


 2017-2018 (March) (with solutions)
Question 3.2.1 | 4.00 marks
Solution Write Any Eight Basic Rules for Virtual Function that Satisfies the Compiler Requirements Concept: C++ Programming.
View in app×