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...

How would you stop a class from class from being derived or
inherited?The constructer should not be Private,as object
instantiation should be allowed.

Answer Posted / vikas

Kamma's answer is right. Here is the explanation:

First a brush of some C++ concepts:

1. In virtual inheritance, the most derived class calls the
virtual base class' c'tor/d'tor.

2. The class declared as 'friend class' can access the
private member functions of a class.

In A a; A' compiler tries to call A::A(), since its declared
as public its called. Now A::A() requires to call its parent
class's c'tor which although private but is able to be
called[1 above].

In C c; C::C() calls B::B()[2 above].
C being a non friend class can't access B::B() which is private.

More at:
http://www.cppquestions.com/viewtopic.php?f=33&t=25

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which one is better- macro or function?

1151


What is ios flag in c++?

1164


Is atoi safe?

1023


How is data hiding achieved in c++?

1046


Are strings immutable in c++?

1135


What is the use of setfill in c++?

1046


What is the difference between structures and unions?

1035


Is c++ platform dependent?

1050


How do you declare a set in c++?

932


Do class declarations end with a semicolon?

1047


What are member functions used in c++?

1110


If a header file is included twice by mistake in the program, will it give any error?

1012


Can you pass an array to a function in c++?

976


What are multiple inheritances (virtual inheritance)?

1032


How static variables and local variablesare similar and dissimilar?

1016