Can we have a private virtual method ?
Answer Posted / gopinath das
Yes , It we can have a private virtual method. It has
nothing to do with inheritance. It only resolve the dynamic
binding . Only difference is that , this method should be
used inside the class defination of the Base .
The derived class may implements the method either
public,private or protected.
Exa:
class A
{
virtual void x(){cout<<"A"<<endl;};
public:
};
class B:public A
{
//virtual void x(){cout<<"B"<<endl;}; // no prob
public:
virtual void x(){cout<<"B"<<endl;};
};
int main()
{
A *a;
B *b=new B;
a=b;
a->fn();
}
Out put:
B
| Is This Answer Correct ? | 4 Yes | 7 No |
Post New Answer View All Answers
What is a superclass in oop?
What is basic concept of oop?
What is polymorphism and why is it important?
What are the two different types of polymorphism?
What is the real life example of polymorphism?
What are the features of oop?
What is the real time example of encapsulation?
What are the 3 pillars of oop?
Can an interface inherit a class?
Why do we use oops?
How does polymorphism work?
Write a c++ program to display pass and fail for three student using static member function
What are the advantages of polymorphism?
what are the ways in which a constructors can be called?
What is polymorphism what is it for and how is it used?