在Bjarne第三版的书中,1.3节中说明了:A C++ nested class does not have access to an object of the enclosing class.
然而在16.2.13中又写到:
A member class (often called a nested class) can refer to types and static members of its enclosing class. It can only refer to non-static members when it is given an object of the enclosing class to refer to. To avoid getting into the intricacies of binary trees, I use purely technical ‘‘f() and g()’’-style examples.
A nested class has access to members of its enclosing class, even to private members (just as a member function has), but has no notion of a current object of the enclosing class.
今天早上我先是被AI给绕晕了,接着我又把AI给绕晕了
```cpp
class Encloser {
private:
struct PrivateType {/* many code here */};
class Nester {
public:
inline const PrivateType& Show() { return member_; }
private:
PrivateType member_;
};
};
```
这段代码请各位评析一下是否可以?
--
FROM 36.163.208.*