Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!huxley!glenn From: glenn@huxley.huxley.bitstream.com (Glenn P. Parker) Newsgroups: comp.lang.c++ Subject: Re: Efficient compilation of virtual functions Message-ID: Date: 29 Aug 90 14:09:54 GMT References: <1990Aug22.193347.18486@ux1.cso.uiuc.edu> <6428@wolfen.cc.uow.oz> <417@taumet.com> <56971@microsoft.UUCP> Sender: glenn@huxley.UUCP Reply-To: (Glenn Parker) Distribution: comp Organization: Bitstream, Inc. Lines: 26 In-reply-to: jimad@microsoft.UUCP's message of 27 Aug 90 21:18:29 GMT In article <56971@microsoft.UUCP> jimad@microsoft.UUCP (Jim ADCOCK) writes: > C++ already provides a way for a class designer to prevent others from > deriving from it: Just make the constructors private. Given that C++ > already gives class designers the right to specify that no class can > be derived from a given class, should compilers be allowed to optimize > on that class's leaf-ness? Should there be a friendlier way to specify > leaf-ness rather than have to specify constructors private? The question was about "leaf" classes, right? Private constructors alone do not imply leaf-ness because they do not completely prevent derivation. A child class may be a friend of the class with private constructors. The only thing private constructors do is prevent users from directly creating instances of the class. This technique is useful when you have a class that must be visible to the outside world, but which must be instantiated in a context controlled by the programmer (either through a derived class, or through a friend class or friend function). Even if this could be construed as implying leaf-ness, it seems that it would make leaf classes pretty useless, except as an obscure optimization. The user would be unable to create instances of the leaf class without going through some contrived protocol. -- -------------------------------------------------------------------------- Glenn P. Parker Bitstream, Inc. uunet!huxley!glenn 215 First Street glenn@bitstream.com Cambridge, MA 02142-1270