2016-02-15 80 views
0
#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; 
} 

细节:num是私有的,所以我觉得TMP不能访问它。但是为什么这个代码可以编译成功C++的访问权限

回答

0

私人领域并不只适用对象?另一类。但可用于同一班级的对象。