Thread View: comp.std.c++
1 messages
1 total messages
Started by John E. Potter
Tue, 20 Feb 1996 18:46
Re: Name lookup for base class (aka strange thing)
Author: John E. Potter
Date: Tue, 20 Feb 1996 18:46
Date: Tue, 20 Feb 1996 18:46
47 lines
2216 bytes
2216 bytes
"Problem" duplicated with IBM xlC.
class B {
protected :
struct B1 {
int i;
};
};
class D : public B {
friend struct D1;
public :
D::B1 b1; // ok B::B1 is accessable to D.
protected :
struct D1 : public D::B1 {
// error: protected member "B::B1" cannot be accessed.
};
};
D::B1 b1; // error: protected member "B::B1" cannot be accessed.
D d;
int x(d.b1.i); // ok d.b1 is public and so is d.b1.i.
ARM pg187: "Member functions of a nested class have no special access to
members of an enclosing class; they obey the usual access rules".
The nested class declaration has no more right to inherit from the
protected types of the enclosing class than do its member functions
to access the protected members. Although not explicitly stated, this
seems consistent. Expert opinion appreciated.
For a concrete example, consider Stroustrup, "The C++ Programming Language",
Section 8.3. Let B == slist_base, B1 == slink, D == Slist, D1 = Tlink.
In that case, it is D : private B and the error messages change to
private member "B::B1".
It seems like a good idea to move the links into the protected areas of
the lists; however, it is not possible.
Enjoy,
John
---
[ To submit articles: Try just posting with your newsreader. If that fails,
use mailto:std-c++@ncar.ucar.edu
FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
Comments? mailto:std.c++-request@ncar.ucar.edu
]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads