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
#include
i got a backdoor offer in process global,Bangalore..Can i work with it?
What is abstract class in oop?
Can you explain polymorphism?
What is oops concept with example?
Is html an oop?
Give two or more real cenario of virtual function and vertual object
What makes a language oop?
Which is better struts or spring?
What are the three main types of variables?
How do you define a class in oop?
Why is oop better than procedural?
Can private class be inherited?
write string class as your own class in java without using any built-in function
How to call a non virtual function in the derived class by using base class pointer