How to declare two classes such that A has members of B and B marks members of A as friends?
- 阅读更多 关于 How to declare two classes such that A has members of B and B marks members of A as friends?
问题 I am attempting to do exercise 7.32 from C++ Primer 5th Edition. That exercise asks the following: Define your own versions of Screen and Window_mgr in which clear is a member of Window_mgr and a friend of Screen . Here are the definitions for Screen , Window_mgr and clear given in the text. class Screen { public: using pos = std::string::size_type; Screen(pos ht, pos wd, char c) : height(ht), width(wd), contents(ht * wd, c) { } private: pos height = 0, width = 0; std::string contents; };