【发布时间】:2016-02-15 10:51:33
【问题描述】:
#include <iostream>
class Base
{
private:
int num;
public:
Base(int tmp = 0) : num(tmp) {}
const Base& operator=(const Base& tmp)
{
num = tmp.num;//why tmp can use num?
return *this;
}
};
int main()
{
return 0;
}
details: num 是私有的,所以我认为tmp 不能访问它。但是为什么这段代码可以编译成功呢?
【问题讨论】:
标签: c++