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 the highest level of cohesion?
What is and I oop mean?
any one please tell me the purpose of operator overloading
How oops is better than procedural?
What is encapsulation in simple terms?
what is different between oops and c++
What is encapsulation with example?
Who invented oop?
What are two types of polymorphism?
Prepare me a program for the animation of train
What is encapsulation and abstraction? How are they implemented in C++?
What is destructor oops?
What is the use of oops?
What do you mean by variable?
What is difference between multiple inheritance and multilevel inheritance?