G
Guest
I'm a Chinese student
I found a very confusable proble
when I studied Visual C++ 6.0
The problem is
#include <iostream.h
class confusable
private
int x,y
public
confusable(int x1,int y1)
x=x1; y=x1
cout<<"In construct !\n"
confusable(confusable & obj)
*this=obj
cout<<"In copy construct !\n"
// 下é¢çš„æžæž„函数 有与没有 令人奇怪 !!
//very confusable below
//~confusable( ){ cout<<"deconstruct ... \n";
}
void main(
{ // 为了便于观察,故æ„将对象数组设置为局部å˜é‡
confusable confuse[2]={ confusable(1,1),confusable(2,2) }
/
1. If I don't define ~confusable( ),the resul
is below
In construct
In copy construct
In construct
In copy construct
2.If I define ~confusable( ),the resul
is below
In construct
In construct
deconstruct ..
deconstruct ..
question
Where is the "In copy construct !"
In my opinion
The result should be
In construct
In copy construct
In construct
In copy construct
deconstruct ..
deconstruct ...
Please tell me why
The reason please!
Easily and clearly
*
I found a very confusable proble
when I studied Visual C++ 6.0
The problem is
#include <iostream.h
class confusable
private
int x,y
public
confusable(int x1,int y1)
x=x1; y=x1
cout<<"In construct !\n"
confusable(confusable & obj)
*this=obj
cout<<"In copy construct !\n"
// 下é¢çš„æžæž„函数 有与没有 令人奇怪 !!
//very confusable below
//~confusable( ){ cout<<"deconstruct ... \n";
}
void main(
{ // 为了便于观察,故æ„将对象数组设置为局部å˜é‡
confusable confuse[2]={ confusable(1,1),confusable(2,2) }
/
1. If I don't define ~confusable( ),the resul
is below
In construct
In copy construct
In construct
In copy construct
2.If I define ~confusable( ),the resul
is below
In construct
In construct
deconstruct ..
deconstruct ..
question
Where is the "In copy construct !"
In my opinion
The result should be
In construct
In copy construct
In construct
In copy construct
deconstruct ..
deconstruct ...
Please tell me why
The reason please!
Easily and clearly
*