Path: utzoo!attcan!uunet!lll-winken!ames!ucsd!rutgers!att!mtuxo!rolls!westmark!mole-end!mat From: mat@mole-end.UUCP (Mark A Terribile) Newsgroups: comp.lang.c++ Subject: Re: inheriting constructors Summary: Base class constructors are *CALLED* ... Message-ID: <141@mole-end.UUCP> Date: 10 Jan 89 08:14:27 GMT References: <3447@tekcrl.CRL.TEK.COM> Organization: mole-end--private system. admin: mole-end!newtnews Lines: 32 > I could find nothing in "the book" or subsequent papers on whether > constructors are inherited by a derived type. Normal functions are > inherited, but in order for a constructor to be inherited, the compiler > needs to recognize that the name of the constructor has changed to be > the name of the derived class. ... Constructors are not inherited. ``Of course'' the base class's constructors *are* called (See B. Stroustrup's book, section 7.2.6) and there is nothing to prevent you from making the derived constructor(s) inline. > ... In particular, when the > derived type merely (re)defines some virtual functions, it is annoying > (and error prone) to have to define constructors for the derived type that > are identical to the base type's constructors. If the constructors are inline and written inline, it's no longer so error prone. > I strongly feel that constructors should be inherited. Is this question > answered anywhere? Is there a good reason why they shouldn't be inherited? I disagree, mostly because the five or six thousand lines of C++ that I've written (not a lot, I realize) have not shown me any real need and because this sounds like it could be a door thrown open to errors of omission in large classes of problems. If you find it necessary, you might want to look for another way to express the type relationships that you have. With a little more experience, I might be able to write some concrete examples; right now I cannot. -- (This man's opinions are his own.) From mole-end Mark Terribile