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.

Answer Posted / srini

#define DO_NOT_DERIVE(T) \
class NoDerive_##T { \
friend class T;
\
NoDerive_##T() {}
\
NoDerive_##T(const NoDerive_##T&) {} \
};
#define stopderiving(T) private virtual NoDerive_##T

when we derive from any class, the constructor needs to be
called, since here constructor of NoDerive calss is
private, it cannot be derived. And friendship cannot be
inherited.
usage
class finalclass : stopderiving (finalclass)
{
....
};

the other possible solution for this is making the default
constructor private.

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is different between oops and c++

2552


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

2114


What is a class and object?

1056


Give two or more real cenario of virtual function and vertual object

2329


Why interface is used?

1024


What is inheritance in simple words?

1058


Can main method override?

1113


What is the advantage of oop over procedural language?

1090


What is abstraction with example?

1115


What is interface in oop?

1133


What is the renewal class?

2763


Why do we use oops?

1024


What are the two different types of polymorphism?

1147


What is the importance of oop?

1099


What is polymorphism explain?

1266