This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Bug in use of base class constructor in inherited class ?


On Apr 13, 2004, Nilmoni Deb <ndeb@ece.cmu.edu> wrote:

> On a totally different matter, since the constructor for obj is invoked
> prior to the constructor for obj2 (which inherits obj), should the
> constructor for obj2 be allowed to invoke the constructor for obj a 2nd
> time ?

You're not invoking the constructor for your instance of obj a 2nd
time.  Using the type-cast notation within the ctor body, you're
creating an unrelated temporary of type obj, whose constructor is
passed `a' and `b' as a arguments.  In order to run the ctor for a
base class, you must use the `: base(args)' notation.

-- 
Alexandre Oliva             http://www.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]