On Wed, 28 Apr 2004 06:55:24 GMT, "bobsled" <> wrote:
>Generally, what should be done to make a class not expected to be derived
>from?
Don't give it any virtual functions and document the fact that it is a
concrete class. It is possible to force non-derivation, but there
generally isn't much point.
>What should be done to a class to make it derivable?
Give it at least one virtual function, and document how that should be
overridden. You will almost always want a virtual destructor too.
>In an abstract base class, the destructor is automatically "virtual?
No, you have to explicitly declare it to be virtual.
>If the constructor of a class is protected or private, how to code the class
>so that it provides a public member function, or to declare a friend that
>has access to the protected or private constructor and thus the class
>becomes instantiable?
friend class MyFriend;
or
public:
static Foo* createFoo() {return new Foo();}
unless I didn't understand the question?
Tom
--
C++ FAQ:
http://www.parashift.com/c++-faq-lite/
C FAQ:
http://www.eskimo.com/~scs/C-faq/top.html