[合集] C++ private member question# Programming - 葵花宝典
c*d
1 楼
☆─────────────────────────────────────☆
arjiang (得失随缘,心无增减) 于 (Sun Jan 14 04:16:46 2007) 提到:
private member of a class
就是其他object不能直接access,
但如果是同一种class的不同instance呢?
如 Student A, B;
A 应该不能直接读取B的private: score 吧
可是为什么assignment operater 总是这样写
Student& operator=(const Student& rhs){
...
this->score=rhs.score;
...
}
难道assignment operator是个特例,还是我理解有问题?
谢谢解惑
☆─────────────────────────────────────☆
goodbug (好虫) 于 (Sun Jan 14 11:36:46 2007) 提到:
You can access private member in your class imp
arjiang (得失随缘,心无增减) 于 (Sun Jan 14 04:16:46 2007) 提到:
private member of a class
就是其他object不能直接access,
但如果是同一种class的不同instance呢?
如 Student A, B;
A 应该不能直接读取B的private: score 吧
可是为什么assignment operater 总是这样写
Student& operator=(const Student& rhs){
...
this->score=rhs.score;
...
}
难道assignment operator是个特例,还是我理解有问题?
谢谢解惑
☆─────────────────────────────────────☆
goodbug (好虫) 于 (Sun Jan 14 11:36:46 2007) 提到:
You can access private member in your class imp