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

CORRECTION to my previous post : please strike out "unless
you define similar create/destroy methods for class Derived
within Base class scope". Does not change the major idea,
just implications - but not well thought over.

The correct way is to declare class Derived as a friend to
class Base - like :
class Base
{
friend class Derived;
...
}

then Derived will be able to access Base's private
destructor. But you don't want to let that happen - as I
said - if you want to prohibit any further derivation. But
if you want to make an exception for some predefined types
derived from Base, that is the way.
Cheers and apologies.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is COPY CONSTRUCTOR and what is it used for?

1039


What is atoi in c++?

1038


What are exceptions c++?

1004


Explain the benefits of proper inheritance.

1104


Explain the difference between new() and malloc() in c++?

1097


What is the difference between an external iterator and an internal iterator? Describe an advantage of the external iterator.

1031


What is the difference between the functions rand(), random(), srand() and randomize()?

1237


What is the difference between struct and class?

1472


What is the use of c++ programming language in real life?

1013


What is stl containers in c++?

1018


What is heap sort in c++?

1028


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

976


what Is DCS ? what i will get benefit when i did?

2323


Is arr and &arr are same expression for an array?

1029


What is the difference between method overloading and method overriding in c++?

1105