Re: [C++] Having some troubles with ctors

From: Alwyn (dt015a1979_at_mac.com.invalid)
Date: 07/31/04


Date: Sat, 31 Jul 2004 14:21:20 +0100

In article <2n1ka7Fqsgj6U1@uni-berlin.de>, Val \
<chrisval@bigpond.com.au> wrote:

> However, my response was due to trying to initialise
> a base class, as in:
> b( char const* s ) : a( str ) {}
>
> ...where 'a' is not a base class of 'b'.

No, that would not work for the reason you stated. If you are
initialising a data member of the class, you have to give the name of
that member, not that of its class.

It would help disambiguate things if it was arranged that class names
started with capital letters and the names of instances with
miniscules.

Alwyn



Relevant Pages

  • Re: inheritance ideas
    ... > function for every data member that is added in a derived ... > simply defining all the member variables in the base class ... Two advantages of using virtual functions are ... should be thinking of *all* the functionality you need in the base class. ...
    (comp.lang.cpp)
  • Re: Item 13 in Meyers Effective C++
    ... Out of ordering initialising should not be done by any compiler. ... You must take care with data member ordering - the ... Out of order initializers don't appear to be ...
    (comp.lang.cpp)
  • Re: inheritance ideas
    ... Okay John, you seem to be approaching this as if I already ... function for every data member that is added in a derived ... simply defining all the member variables in the base class ... >> members in the base class. ...
    (comp.lang.cpp)