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 does and I oop and sksksk mean?
Why do we use inheritance?
What does and I oop mean?
What is overloading and its types?
Templates mean
What is oops in simple words?
What is oops with example?
what type of question are asked in thoughtworks pair programming round ?
What is polymorphism and example?
What is abstraction in oops?
write a C++ program for booking using constructor and destructor.
How do you achieve polymorphism?
State what is encapsulation and friend function?
What is abstraction in oops with example?
What is a function in oop?