64,660
社区成员
发帖
与我相关
我的任务
分享
class Box
{
public:
Box(){ this->num = 0;}
Box(int num)
{
this->num = num;
}
Box(const Box& temp)
{
this->num = temp.num+100;
}
void show()
{
cout<<this->num<<endl;
}
int num;
};
Box get() // 返回值是对象!!! 是否这时调用了拷贝构造函数?
{
Box box1(2);
return box1;
}
int main(int argc, char *argv[])
{
Box box;
box = get();
box.show();
return 0;
}