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 / sriram

We can have the private virtual method. But it can be
accessed only through the derived class not through the
base class.

class A
{
private:
virtual void fun() { std::cout << "A::fun" <<
std::endl; }

};

class B : public A
{
public:
virtual void fun() { std::cout << "B::fun" <<
std::endl; }

};

int main(int argc, char* argv[])
{
A* pa = new A();
((B*)(pa))->fun();
}

Output : A::fun

Is This Answer Correct ?    4 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is encapsulation in oop?

990


I have One image (means a group photo ) how to split the faces only from the image?............ please send the answer nagadurgaraju@gmail.com thanks in advace...

2050


What is a superclass in oop?

1112


Which method cannot be overridden?

1021


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

3328


What do you mean by variable?

977


What is balance factor?

1020


Prepare me a program for the animation of train

2414


Can you explain polymorphism?

1047


What is polymorphism give a real life example?

976


What is the problem with multiple inheritance?

1098


What does it mean when someone says I oop?

1018


2. Give the different notations for the class.\

2086


What is difference between pop and oop?

1077


How to hide the base class functionality in Inheritance?

1093