constructor problem
Marco Welti
marco.welti@fantastic.com
Mon Feb 21 04:57:00 GMT 2000
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
>
More information about the Cygwin
mailing list