Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is a superclass in oop?

1177


What is basic concept of oop?

1170


What is polymorphism and why is it important?

1042


What are the two different types of polymorphism?

1145


What is the real life example of polymorphism?

1177


What are the features of oop?

1181


What is the real time example of encapsulation?

1070


What are the 3 pillars of oop?

1193


Can an interface inherit a class?

1067


Why do we use oops?

1019


How does polymorphism work?

1144


Write a c++ program to display pass and fail for three student using static member function

3400


What are the advantages of polymorphism?

1033


what are the ways in which a constructors can be called?

2139


What is polymorphism what is it for and how is it used?

1023