Questions tagged «friend-class»

2
复制和移动构造函数自动成为朋友吗?
当我们定义复制或移动构造函数时,我们可以访问另一个类的私有变量。C ++是否会friend自动使它们彼此交互? 例如: my_str::my_str(my_str&& m) { size_ = m.size_; //accessing private variable another my_str class buff_ = m.buff_; //accessing private variable another my_str class m.buff_ = nullptr; m.size_ = 0; }
14 c++  friend-class 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.