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 are the different types of polymorphism in c++?

1067


How to declare a function pointer?

956


What is atoi?

925


What is data abstraction? How is it different from data encapsulation?

946


Can constructor be private in c++?

982


Is C++ case sensitive a) False b) Depends on implementation c) True

1019


Is c++ double?

980


What is a constructor in c++ with example?

1073


What is a class template in c++?

1005


How many types of classes are there in c++?

986


What is iterator in c++?

1058


What is size_type?

971


Define Virtual function in C++.

1038


Explain the concept of dynamic allocation of memory?

1048


What is a stack c++?

955