hello,
When i run the below code i am getting the value of copyconscount as 2 and not 3 Please tell me why is it happening?the copy constructor is called thrice in the program and still why is it showing only 2??
Code:#include <iostream.h> class room { int width; int height; static int copyconscount; public: room() { width=12; height=8; } room(room &r) { width=r.width; height=r.height; copyconscount++; } void dispcopyconscount() { cout<<copyconscount; cout<<endl<<height; cout<<endl<<width; } }; int room::copyconscount; int main(void) { room objroom1; room objroom2(objroom1); room objroom3=objroom1; room objroom4; objroom4=objroom3; objroom4.dispcopyconscount(); return 0; }



LinkBack URL
About LinkBacks


