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


Dear Leonhard,

This is just C++. In your first constructor, you are just constructing a
local object with the 1st constructor. You are not 'calling the constructor
function on the same object'. Constructors are not ordinary functions.

To do something like you want, you would have to have a 3rd function

class A
{
  A() { f(); }
  A(int a) { f(); /*do something with a*/ };
  void f() { /*blabla*/ }
};

There are some restrictions on which functions you can call from within
constructors though (notably: do not call virtual functions).

Kris


> -----Original Message-----
> From: cygwin-owner@sourceware.cygnus.com
> [mailto:cygwin-owner@sourceware.cygnus.com]On Behalf Of Leonhard
> Grünschloß
> Sent: 21 February 2000 13:44
> To: cygwin@sourceware.cygnus.com
> Subject: constructor problem
>
>
> I don't know if that's Cygwin specific, but that's my problem:
> If I call a second constructor from the first constructor it is
> called, but
> the (private) variables it changed aren't changed when it returns to the
> first constructor. Why not? How else can I call the constructor
> so that its
> actions aren't "undone"?
> --OyL


--
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]