TITLE: Classes that cannot be derived from PROBLEM: Christopher Walsh [...] I'm wondering if the language has the ability to create a class that cannot be inherited. [...] RESPONSE: jamshid@ses.com (Jamshid Afshar), 3 Mar 94 You could make the destructor private, but then you couldn't declare such objects on the stack, or as globals or members of other classes. You would would also have to define and use a deleteme() member function instead of using the delete operator. Btw, a solution for Lippman's example is just to forward the operator new()/delete() call to the global versions if the size is greater than sizeof(ThisClass). I personally would probably just let it go with a comment, but if you really want a compile-time error when someone tries to inherit from your class, try the following trick that was posted here a while back (recalled from memory): class Sterile_ForceLeaf { // dummy class friend class Sterile; Sterile_ForceLeaf() {} // note this is private }; class Sterile : private virtual Sterile_ForceLeaf { public: Sterile() {} Sterile(const char* /*blah*/) {} }; class Illegitimate : public Sterile { public: Illegitimate() {} // error: can't access virtual base default ctor Illegitimate(const char* /*blah*/) : Sterile_ForceLeaf() {} // error: can't access virtual base default ctor Illegitimate(const Illegitimate&) {} // error: can't access virtual base default ctor }; This trick relies on the fact that the most derived class always calls any virtual base constructors. Note, you can even make "ForceLeaf" a class template so you don't have to define one for every class you want to be "sterile". Warning: g++ 2.5.5 fails to flag the above errors and Cfront fails to handle the following template version. template class ForceLeaf { friend class T; ForceLeaf() {} }; class Sterile : private virtual ForceLeaf { public: Sterile() {} Sterile(const char* /*blah*/) {} };