Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Why ambiguous base when one is inherited private?

Reply
Thread Tools

Why ambiguous base when one is inherited private?

 
 
a eriksson
Guest
Posts: n/a
 
      08-09-2005
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

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      08-09-2005
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
private inheritance and ambiguous base nguillot C++ 5 02-24-2011 09:41 AM
can I turn base object into inherited one? alexl C++ 5 04-14-2008 08:28 AM
'Class.inherited' v. 'inherited' syntax inside Class 7stud -- Ruby 11 11-09-2007 06:45 PM
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57