0
Will anyone will see my error???
4 ответов
+ 11
Kajal Kumari
You're Inheriting class A in both class B and class C.
So class B and class C will contain the function " showa( ) " of class A.
By inheriting class A and class B virtually in class D your errors for ambiguity will remove.
But there will be one error -
" showc wasn't declared in this scope "
Reason - Because you want print 'C' by showc() which is in Derived class D " without inheriting class C " ( as class C contains showc( ) function )
So , to remove this error you have to inherit class C ( instead of class A ) in derived class D .
You can also do this as Robert Atkins code but in his code there is " multilevel inheritance ".
And for your code -
https://code.sololearn.com/cyLqwzbYAoN4/?ref=app
+ 1
I think the problem lies in the fact that class D is inheriting from class B and class A, since class B already inherits from class A it confuses the compiler throwing that ambiguity error, here i modified your code a bit
https://code.sololearn.com/cnMe87IzY6E5/?ref=app
Also, just for future posts, please have some organization to your code, indents and such, not only will it help out other readers of your code, but also yourself when you come back to it at a later date.
+ 1
I can't use virtual function here???to remove ambiguity error
+ 1
Thanku sooo much