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

Mms, thanks for arising my curiosity on the subject -
actually, there is very elegant solution to make class no
inheritable and allow it on stack. The idea is to virtually
inherit from base class with private destructor. Virtual
inheritance will force derived classes to call virtual base
destructor first, and it would be impossible because its is
private. Much better than solution I described, must admit.
Ok, here is the link with very good description :
http://www.codeguru.com/cpp/cpp/cpp_mfc/stl/article.php/c4143/

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are iterators in c++?

980


Why c++ is not a pure oop language?

1003


What are the important differences between c++ and java?

1110


What are inline functions? What is the syntax for defining an inline function?

1117


How can you quickly find the number of elements stored in a dynamic array? Why is it difficult to store linked list in an array?

1007


Can a new be used in place of old mallocq? If yes, why?

1055


Can we define a constructor as virtual in c++?

1096


what is c++

2337


What are the 2 main types of data structures?

1088


What is function declaration in c++ with example?

1038


Who created c++?

1031


What is a c++ object?

1118


Which operations are permitted on pointers?

964


What is pointer -to-members in C++? Give their syntax?

1003


Explain how we implement exception handling in c++?

1023