Topic: Accessibility of base classes and base class members (CD2 11.2 Par.4)
Author: Koji Uchiyama <uchiyama@tool.mesc.co.jp>
Date: 1998/06/09 Raw View
Is p->B::m() legal in the following ?
class B {
public:
static void m();
};
class D : private B { };
D*p;
void h()
{
// B::m(); // m is accessible
// p->m(); // m is not accessible
p->B::m(); // is it accessible ?
}
According to CD2 11.2 "Accessibility of base classes and base class members"
paragraph 4, it seem to me that p->B::m() is legal,
even though p->m() is not legal:
1. "naming class" is B
2. m as a member of B is public
3. as a result, m is accessible
g++-2.8.2 says:
fields of `B' are inaccessible in `D' due to private inheritance
This message looks reasonable,
but I could not find why p->B::m() is not legal in CD2.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]