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
write a program to find 2 power of a 5digit number with out using big int and exponent ?
What is abstraction oop?
What does and I oop mean?
What is difference between polymorphism and inheritance?
Which type does string inherit from?
What is destructor give example?
What is the diamond problem in inheritance?
What is the oops and benefits of oops programming?
What does enum stand for?
What is object and example?
How do you answer polymorphism?
What is abstract class in oops?
What does no cap mean?
What are the two different types of polymorphism?
What is inheritance and how many types of inheritance?