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 polymorphism give a real life example?
What is abstraction and encapsulation?
write a code for this. serial_number contained in the header of the file will be read , if this serial number is less than a previous serial number within a successfully processed file, or is the same as another serial number within a successfully processed file, or if the field contains anything other than 7 digits, then the file must error with the reason ‘Invalid SERIAL_NUMBER’.
Whats oop mean?
write a programe to calculate the simple intrest and compund intrest using by function overlading
What are the 3 principles of oop?
Can you explain polymorphism?
What is byval and byref? What are differences between them?
What polymorphism means?
What is Difeerence between List obj=new ArrayList(); and ArrayList obj=new ArrayList()?
What is destructor give example?
What are the features of oop?
What is the fundamental idea of oop?
#include
What is interface in oop?