help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: struct member initialization


From: Paul Pluzhnikov
Subject: Re: struct member initialization
Date: Tue, 02 Jan 2007 06:38:59 -0800
User-agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux)

ferns-paanakker@hotmail.com writes:

> To correct this I want to perform member
> initialization, but I have no idea how to do this correctly.

Add initializing constructor to MyDate:

> typedef struct MyDate
> {
>   unsigned short year;
>   unsigned short month;
>   unsigned short day;
    MyDate() : year(0), month(0), day(0) { }
> } MyDate;
>
>
> class
> {
> public:
>       MyTest();
> private:
>       MyDate date;
> }
>
> void MyTest::MyTest() :
// >   date.year(0) -> this doesn't work. What syntax should i use?
     MyDate()
> {
      ...
> }

Cheers,
-- 
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]