Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #3497
| From | Victor Bazarov <v.bazarov@comcast.invalid> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: // how can I access A::a? |
| Date | 2011-04-12 13:34 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <io22er$be8$1@dont-email.me> (permalink) |
| References | <bee3f0ea-42ae-4ae4-a254-d5bc9e004f93@k5g2000yqj.googlegroups.com> <2011041207385159183-pete@versatilecodingcom> |
On 4/12/2011 7:38 AM, Pete Becker wrote:
> On 2011-04-11 18:52:40 -0400, dick said:
>
>> /* multi_level_inheritance.cpp */
>> struct A
>> {
>> int a;
>> };
>>
>> struct B1 : public A
>> {
>> int a;
>> };
>>
>> struct B2 : public A
>> {
>> int a;
>> };
>>
>> struct C : public B1, public B2
>> {
>> int a;
>> };
>>
>> int main()
>> {
>> C ccc;
>>
>> ccc.a=123;
>>
>> ccc.B1::a=456;
>>
>> /* 0030 */ ccc.B1::A::a=789;
>>
>> }
>>
>> // c++ multi_level_inheritance.cpp
>> // multi_level_inheritance.cpp: In function int main():
>> // multi_level_inheritance.cpp:30: error: A is an ambiguous base of C
>>
>>
>> // how can I access A::a?
>
> There are two A::a's, which is why the error message said that the
> reference to A is ambiguous. You need to decide which one you want to
> access, then name it. Hint: there's one in B1 and one in B2.
And does the fact that the OP specifically used 'B1::' before 'A::a'
matter not?
V
--
I do not respond to top-posted replies, please don't ask
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
// how can I access A::a? dick <dick_12345678@hotmail.com> - 2011-04-11 15:52 -0700
Re: // how can I access A::a? Carlo Milanesi <carlo.nospam.milanesi@libero.it> - 2011-04-12 01:08 +0200
Re: // how can I access A::a? dick <dick_12345678@hotmail.com> - 2011-04-11 16:56 -0700
Re: // how can I access A::a? Carlo Milanesi <carlo.nospam.milanesi@libero.it> - 2011-04-12 18:46 +0200
Re: // how can I access A::a? Miles Bader <miles@gnu.org> - 2011-04-13 15:57 +0900
Re: // how can I access A::a? Pete Becker <pete@versatilecoding.com> - 2011-04-12 07:38 -0400
Re: // how can I access A::a? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-04-12 13:34 -0400
Re: // how can I access A::a? Pete Becker <pete@versatilecoding.com> - 2011-04-12 14:20 -0400
Re: // how can I access A::a? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-04-12 15:01 -0400
Re: // how can I access A::a? Pete Becker <pete@versatilecoding.com> - 2011-04-12 15:13 -0400
csiph-web