Article View: alt.comp.lang.learn.c-c++
Article #348Re: class definition
From: Gryff
Date: Tue, 30 Nov 1999 00:00
Date: Tue, 30 Nov 1999 00:00
66 lines
3103 bytes
3103 bytes
G'day,
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?
> }
Because derived is a specialisation of base then all of the properties
of an object of type base are necessarily properties of an object of
type derived. This constructor for a derived object causes the base
bits to be properly constructed by including the base constructor in the
initialisation list.
>
> I see this kind of declaration in an example of OWL programming and in
> the case derived is TDrawApp and base is TApplication.
>
> Well, something out of the content but I saw this in my C++ book and I
> can't make clear of them:
>
Favoured by pathological teachers as exam questions and more than likely
the last time you will see such evil (although I must admit to writing
something similarly nasty in C to adapt some legacy code).
The trick is to start at the symbol and work outwards keeping track of
precedences and associativity. Here goes <deep breath>
> int *(*(*ifunct_ptr)(int))[5];
A declaration of ifunct_ptr which is a pointer to a function that takes
one int argument and returns a pointer to an array of 5 pointers to int
> float (*(*ffunct_ptr)(int,int))(float);
A declaration of ffunct_ptr which is a pointer to a function that takes
2 int arguments and returns a pointer to a function that takes one
float argument and returns a float
> typedef double (*(*(*dfunct_ptr)())[5])();
A type definition for dfunct_ptr which is defined as a pointer to a
function that takes no arguments and returns a pointer to an array of 5
pointers to functions that take no arguments and return doubles
> (*(*funtion_ary_ptrs())[5])();
A statement comprising a call to function_ary_ptrs, then dereferencing
the return value (which will be a pointer to an array of pointers to
functions that take no argument) and calling the sixth element
(function) in that array.
> int func() const;
This is a declaration of a member function that takes no argument,
returns an int and does not change the object of which the method is a
property.
Cheers,
Gryff
Technical Details
Message-ID:
<3843A6DD.C2CB147B@eyeeyenet.net.au.invalid>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<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: Gryff <stokoe@eyeeyenet.net.au.invalid> Subject: Re: class definition Date: 1999/11/30 Message-ID: <3843A6DD.C2CB147B@eyeeyenet.net.au.invalid> X-Deja-AN: 554794039 Content-Transfer-Encoding: 7bit References: <38436F07.55AD215F@netvigator.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Trace: news.iinet.net.au 943957675 2246 O81cyj@203.59.80.170 MIME-Version: 1.0 Newsgroups: alt.comp.lang.learn.c-c++,comp.lang.c++,borland.public.cpp.language