🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.comp.lang.learn.c-c++
Article #350

Re: class definition

#350
From: Ron Natalie
Date: Tue, 30 Nov 1999 00:00
29 lines
1653 bytes

Bruce Lai wrote:
> 
>     Hello great programmers, I got a question here. Please take a look
> at the code below.
> 
>     class derived : public base {
>         public:
>             derived()  :  base() {}  //What the hell does this line of
> code do?
>     }
> 
The stuff after the colon in a constructor declaration provides
information
on intializing either base or member variables.  However in this case
it specifies exactly what would have happened anyhow (derived default
construtor invokes base default constructor), so it's unclear why it was
written this way.  COnsider:

	derived::derived() : base('d') {  ...

This would ininitialize the base class with the char literal 'd'.

Note that specifying these initializers only provides the arguments
to initialize the listed base classes or members.  It DOES NOT change
the order of construction.

-Ron
Technical Details
Message-ID: <3843E40D.3E345FBA@sensor.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <38436F07.55AD215F@netvigator.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f8d38,1c86b0ff88e63dee
X-Google-Attributes: gidf8d38,public
X-Google-Thread: 114592,1c86b0ff88e63dee
X-Google-Attributes: gid114592,public
X-Google-Thread: 109fba,1c86b0ff88e63dee
X-Google-Attributes: gid109fba,public
From: Ron Natalie <ron@sensor.com>
Subject: Re: class definition
Date: 1999/11/30
Message-ID: <3843E40D.3E345FBA@sensor.com>
X-Deja-AN: 554870679
Content-Transfer-Encoding: 7bit
References: <38436F07.55AD215F@netvigator.com>
To: Bruce Lai <arraylai@netvigator.com>
X-Accept-Language: en
Content-Type: text/plain; charset=x-user-defined
Organization: Sensor Systems
Mime-Version: 1.0
Newsgroups: alt.comp.lang.learn.c-c++,comp.lang.c++,borland.public.cpp.language