class E
{
public:
int *num; // 指標必須再new 1份
E& operator=(const E& rhs)
{
this->num = new int((*rhs.num)); // 避免互相影響
return *this;
}
}
class A
{
//member operator
A& operator+=(const A& rhs)
{
this->num += rhs.num;
return *this;
}
int num;
};
E test1;
*test1.num = 5;
E test2;
test2 = test1;
沒有留言:
張貼留言