Topic: Absurd access rules for nested classes


Author: jbn@lulea.telesoft.se (Johan Bengtsson)
Date: 5 Jul 91 17:12:07 GMT
Raw View
I need to formulate the exact rules for access in C++, but
I can't find sane rules for types declared inside an enclosing
(nesting) class.

I want the "standard" rules, for now that is what is described
in [ARM 1990], but later I wish to support ANSI C++.

Quotes from [ARM 1990]:

p239: "Access control applies uniformly to function members,
 data members, member constants and nested types."

p187: "Member functions of nested classes have no special access to
 members of an object of the enclosing class; they obey the
 usual access rules."

I now give you the following absurdity, interpreted according to the quotes:

class Enclosing {
private:
 class Inner {
  Inner(const Inner&);  // error? class Inner is private!
 };
};

Does the quote from p187 imply that the *entire* class Inner has
no "special" access to class Enclosing? If it does, then class
Inner has no access rights to its own name, because it is private!

Surely we must be able to define private classes within an enclosing class?

Am I missing something here?

Will ANSI C++ have the same formulations, or will nested classes be
"proper" members of enclosing classes, having full access (I hope so)?

Sun C++ 2.0 makes class Inner public, and has problems with other
nested types. Yes, I know that C++ 2.1 (coming to us soon) is supposed
to support nested classes properly.


-- Johan


---------------------------------------------------------------
| Johan Bengtsson              Email: jbn@lulea.telesoft.se   |
| Telesoft AB                  Fax:   (+46) 920 754 90        |
| Aurorum 6                    Voice: (+46) 920 754 71        |
| S-951 75 Lulea                                              |
| SWEDEN                                                      |
---------------------------------------------------------------