Discussion:
Why ambiguous base when one is inherited private?
(too old to reply)
a eriksson
2005-08-09 13:17:41 UTC
Permalink
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
Victor Bazarov
2005-08-09 13:55:37 UTC
Permalink
Post by a eriksson
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

Continue reading on narkive:
Loading...