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 constructor in oop?

1110


String = "C++ is an object oriented programming language.An imp feature of oops is classes and objects".Write a pgm to count the repeated words from this scenario?

2386


What is polymorphism explain its types?

1160


State what is encapsulation and friend function?

1264


What is polymorphism give a real life example?

1034


What are the 5 oop principles?

1124


What is the main purpose of inheritance law?

1197


What is the difference between inheritance and polymorphism?

1112


Who invented oop?

1132


What are the two different types of polymorphism?

1143


Why do while loop is used?

1035


How can you overcome the diamond problem in inheritance?

1183


given a set based questions and 5 questions based on it next data sufficiciency questions 2 and 2/3 english sentence completion with options very easy and 2 synononmys paragraph with 10 questions 10 minutes replace =,-,*,% with -,%,+,* type questions 5 3 questions lik following itssickhere itssickthere itssickhere istsickhere which is nt alike the others very easy

2625


What are functions in oop?

1056


Whats oop mean?

1039