RE: [Dev-C++] Constructor and Destructor
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ioannis V. <iv...@em...> - 2003-07-10 12:15:15
|
You need a thorough, slow read of a good, up to date ANSI/ISO C++ introductory book. You can check http://www.accu.org at the book reviews section. Regards, Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net > -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Verma, Lohit > Sent: Thursday, July 10, 2003 9:50 AM > To: 'Per Westermark'; 'dev...@li...' > Subject: RE: [Dev-C++] Constructor and Destructor > > > Hi, > I take your point regarding not using delete this in constructor. > > Now you had said that as the function in a class does not > access / update > any data member it works. > In the following program I have specifically set the value of a data > member,this still works. > > #include <iostream> > using namespace std; > > class A{ > int i; > public: > A(){ > cout<<"A const\n"; > } > void f(){ > cout<<"F\n"; > i=9; > cout<<"FUNC I "<<i<<endl; > } > void g(){ > cout<<"G I "<<i<<endl; > } > ~A(){ > cout<<"DEST\n"; > } > }; > int main(){ > A *b; > b->f(); > return 1; > } > > OUTPUT > F > FUNC I 9 > G I 9 > > This doesnt make sense to me!!! > I have tried it on both windows and solaris. > > Any ideas?? > Regards > Lohit |