[Example 1: struct Node {struct Node* Next; // OK: Refers to injected-class-name Nodestruct Data* Data; // OK: Declares type Data at global scope and member Data};
struct Data {struct Node* Node; // OK: Refers to Node at global scopefriendstruct::Glob; // error: Glob is not declared, cannot introduce a qualified type ([dcl.type.elab])friendstruct Glob; // OK: Refers to (as yet) undeclared Glob at global scope./* ... */};
struct Base {struct Data; // OK: Declares nested Datastruct::Data* thatData; // OK: Refers to ::Datastruct Base::Data* thisData; // OK: Refers to nested Datafriendclass::Data; // OK: global Data is a friendfriendclass Data; // OK: nested Data is a friendstruct Data {/* ... */}; // Defines nested Data};
struct Data; // OK: Redeclares Data at global scopestruct::Data; // error: cannot introduce a qualified type ([dcl.type.elab])struct Base::Data; // error: cannot introduce a qualified type ([dcl.type.elab])struct Base::Datum; // error: Datum undefinedstruct Base::Data* pBase; // OK: refers to nested Data — end example]