高手!高手!高高手!!
10楼的帖子实在是经典!!!
![](/skin/img/sigline.gif)
反清复明 http://xupeng.
[此贴子已经被作者于2006-2-24 6:42:27编辑过]
CToolBarCtrl类中定没定义复制构造函数?如果定义了,那就用=附值呗,干吗非加&。如果
没定义,光加&就能解决问题吗?我查了C++宝典了,人家使用复制构造函数时只用了=,没用&。到底咋回
事?
#include <iostream>
using namespace std;
class A
{
private:
int a;
public:
A(){a = 0;}
A(int value){a = value;}
void display(){ cout<<a<<endl;}
};
class B
{
private:
A a;
public:
B(const A & aa){ a = aa;}
A & test(){return a;}
};
int main()
{
A a(6);
a.display();
B b(a);
A & aa = b.test(); // pay attention here
// 请你将这个 & 去掉,你看看运行的结果是什么
aa.display();
return 0;
}