469,907 Members | 2,170 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,907 developers. It's quick & easy.

Why ambiguous base when one is inherited private?

Why is the call foo(c) below ambiguous when B inherits A privately? I
think that that contradicts the first error reported below since B
objects are not treated as A objects?

class A {};

class B : private A {};

class C : public B, public A {};

void foo(A& a) {}

int main() {
B b;
// foo(b); error: `A' is an inaccessible base of `B'
C c;
foo(c); // error: `A' is an ambiguous base of `C'
}

/ Andreas

Aug 9 '05 #1
1 3546
a eriksson wrote:
Why is the call foo(c) below ambiguous when B inherits A privately? I
think that that contradicts the first error reported below since B
objects are not treated as A objects?

class A {};

class B : private A {};

class C : public B, public A {};

void foo(A& a) {}

int main() {
B b;
// foo(b); error: `A' is an inaccessible base of `B'
C c;
foo(c); // error: `A' is an ambiguous base of `C'
}


Overload resolution happens before checking access privileges.

V
Aug 9 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Andy | last post: by
2 posts views Thread by Michi Henning | last post: by
5 posts views Thread by Chris Szabo | last post: by
7 posts views Thread by relient | last post: by
8 posts views Thread by Mike - EMAIL IGNORED | last post: by
12 posts views Thread by Robert W. | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.