By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,918 Members | 1,557 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,918 IT Pros & Developers. It's quick & easy.

Private inheritance vs internal class declaration

P: n/a
MSVC seems to have a tough time with this program:
struct A
{
struct L
{};
};

struct B: private A::L
{
struct L
{};
};

struct C: public B::L // <-- Error: see below
{
};

int main()
{
C c;
}

---
error C2247: 'A::L' not accessible because 'B' uses 'private' to inherit from
'A::L'

It seems to me that A::L and B::L are completely different classes, and the
fact that B inherits privately from A::L should effectively hide the A::L
interface from B's users.

It also seems that MSVC is the only compiler complaining about this. Both g++
and Metrowerks CodeWarrior accept the code. Is this an MSVC bug, or am I
getting the standard mixed up?

-dr
Jun 13 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Dave Rahardja <dr****************************@pobox.comwrote:
MSVC seems to have a tough time with this program:
struct A
{
struct L
{};
};

struct B: private A::L
{
struct L
{};
};

struct C: public B::L // <-- Error: see below
{
};

int main()
{
C c;
}

---
error C2247: 'A::L' not accessible because 'B' uses 'private' to inherit from
'A::L'

It seems to me that A::L and B::L are completely different classes, and the
fact that B inherits privately from A::L should effectively hide the A::L
interface from B's users.

It also seems that MSVC is the only compiler complaining about this. Both g++
and Metrowerks CodeWarrior accept the code. Is this an MSVC bug, or am I
getting the standard mixed up?
It compiles with Comeau Online, so I am inclined to say it is an MSVC
bug.

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
Jun 13 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.