This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


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

RE: constructor problem


Title: RE: constructor problem

> I don't know if that's Cygwin specific, but that's my problem:

This is not a cygwin problem, but it is not possible with c++ !!

class A
{
    A(int a) : A(a, 5) {}
    A(int a, int b) : a_(a), b_(b) {}

   private:
     int a_;
     int b_;
};

main()
{
   A a(1)
}

> If I call a second constructor from the first constructor it
> is called,

Yep, second constructor gets called, but probably not the way you think ;-)

> but
> the (private) variables it changed aren't changed when it
> returns to the
> first constructor.

> Why not?

Because you are ceating a second, local, object which is destroyed as soon as
the (second) constructor finishes.
 
> How else can I call the
> constructor so that its
> actions aren't "undone"?

You can't (at least in c++) ;-(

regards
Marco
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com
>
>
> --
> Want to unsubscribe from this list?
> Send a message to cygwin-unsubscribe@sourceware.cygnus.com
>


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