c++
Which one of the following is the correct way to declare a pure virtual function?
O A. virtual void Display(vold)0);
OB. virtual vold Display = 0;
OC. virtual vold Display(vold) = 0;
D. void Display(vold) = 0;
Answers
Answered by
0
Answer:
B is the crrct answer
Explanation:
brainlest answer mark it
Answered by
0
Answer:
Option b is the correct answer.
B. virtual void Display = 0;
Explanation:
Virtual Function
- A virtual function is a member function that is declared within a parent class and is re-defined by a child class.
- When you refer to a derived class object using a pointer to the parent class, you can call a virtual function for that object and execute the child class’s version of the function.
- They ensure that the correct function is called for an object, regardless of the type of reference used for the function call.
- The virtual function makes it possible to achieve Runtime polymorphism
- Functions are declared with a virtual keyword in the parent class.
There are the following rules that must be obeyed for creating a virtual function:
- It cannot be declared with the static keyword.
- A virtual function can be a friend function of another class.
- Virtual functions should be accessed using a pointer of the parent class type to achieve runtime polymorphism.
- The signature of virtual functions should be the same in the parent as well as the child class.
#SPJ2
Similar questions