RE: [Dev-C++] Constructors for classes
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ioannis V. <iv...@em...> - 2003-06-07 23:32:13
|
> -----Original Message----- > From: dev...@li...=20 > [mailto:dev...@li...] On Behalf=20 > Of Socha, David F > Sent: Saturday, June 07, 2003 2:35 PM > To: Dev C++ Mailing List > Subject: [Dev-C++] Constructors for classes >=20 > node* root =3D new node(5); >=20 > that should alocate the memory, call the constructor, and set=20 > the data portion of the node to 5. > the constructor that is called is the one that will assign a=20 > value to data not the default constructor that does nothing, right? No, it is not the default constructor. There are two types of "default constructors". The default constuctor = and the default copy constructor. If you define them, the defined ones get called. There is no other type of "default constructor" so if you had = not defined the one getting the int, you would get an error. The other default thing is the default assign operator (that is =3D). = Both the default copy constructor and the default assign operator copy the exact = data member values. When defined, the defined ones get called. Ioannis Vranos =20 * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net |