[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]