Answer Posted / qapoo
A function is declared virtual in base class when u are
having same functions in both base and derived classes and
you want to access both the functions with same function
call and its done using base class pointer.
e.g
class base
{
public:
void show(){cout<<"hi"};
};
class derived:pubic base
{
public:
void show(){cout<<"bye";}
};
int main()
{
base *ptr;
base b;
derived d;
ptr=&b;
ptr->show();//base class fn is called
ptr=&d;
ptr->show();//derived class fn is called
return 0;
}
| Is This Answer Correct ? | 7 Yes | 3 No |
Post New Answer View All Answers
hi all..i want to know oops concepts clearly can any1 explain??
What is and I oop mean?
class type to basic type conversion
What are the three main types of variables?
Whats oop mean?
What is object in oop?
Is react oop?
What are the 4 main oop principles?
What is destructor example?
Why is static class not inherited?
What are the advantages of polymorphism?
Why do we use polymorphism in oops?
What type of loop is a for loop?
Following are the class specifications: class {int a}; class {int b}; Using friend funtion,calculate the max of two objects and display it.
What is difference between pop and oop?