Inheritance problem.

Kindly Remove its errors and tell me the reason for the error.
Code couldn't be posted because of word limit so:
Code:
https://www.box.com/s/enl4h6loqcnc7jqqgujq
Kindly Remove its errors and tell me the reason for the error.
I have only one error:
fatal error: conio.h: No such file or directory

What exact errors do you have?
--------------------Configuration: Project - Win32 Debug--------------------
Compiling...
Project.cpp
D:\VC 6.0\Project\Project.cpp(229) : error C2250: 'link' : ambiguous inheritance of 'masterCard::calculate'
D:\VC 6.0\Project\Project.cpp(147) : see declaration of 'masterCard'
D:\VC 6.0\Project\Project.cpp(229) : error C2250: 'link' : ambiguous inheritance of 'visaCard::calculate'
D:\VC 6.0\Project\Project.cpp(157) : see declaration of 'visaCard'
D:\VC 6.0\Project\Project.cpp(229) : error C2250: 'link' : ambiguous inheritance of 'localCard::calculate'
D:\VC 6.0\Project\Project.cpp(180) : see declaration of 'localCard'
D:\VC 6.0\Project\Project.cpp(315) : error C2250: 'll' : ambiguous inheritance of 'masterCard::calculate'
D:\VC 6.0\Project\Project.cpp(147) : see declaration of 'masterCard'
D:\VC 6.0\Project\Project.cpp(315) : error C2250: 'll' : ambiguous inheritance of 'visaCard::calculate'
D:\VC 6.0\Project\Project.cpp(157) : see declaration of 'visaCard'
D:\VC 6.0\Project\Project.cpp(315) : error C2250: 'll' : ambiguous inheritance of 'localCard::calculate'
D:\VC 6.0\Project\Project.cpp(180) : see declaration of 'localCard'
Error executing cl.exe.

Project.obj - 6 error(s), 0 warning(s)
This is because of unneeded use of virtual inheritance. Do not use virtual inheritance unless you absolutely need to do so. Even in those cases think about changing your program design first.
http://www.cprogramming.com/tutorial/virtual_inheritance.html
read Delegating to a sister class part.
Last edited on
I'm reading...
I'm standing where I was.
Remove virtual inheritance from all of your classes. Why did you make it virtual in first place? There is many special rules regarding virtual inheritance and it is better to not touch it unless you know exactly what and why are you doing this and what consequences will follow.
Last edited on
Have a look at this: http://i.imgur.com/3EmTjoQ.png

If I modify my code:
Code:
https://www.box.com/s/1il6ej6b9w20ntyfo630
Error is reduced to 1:

--------------------Configuration: Project - Win32 Debug--------------------
Compiling...
Project.cpp
D:\VC 6.0\Project\Project.cpp(414) : error C2385: 'll::creditCardType' is ambiguous
D:\VC 6.0\Project\Project.cpp(414) : warning C4385: could be the 'creditCardType' in base 'creditCard' of base 'masterCard' of class 'll'
D:\VC 6.0\Project\Project.cpp(414) : warning C4385: or the 'creditCardType' in base 'creditCard' of base 'visaCard' of class 'll'
D:\VC 6.0\Project\Project.cpp(414) : warning C4385: or the 'creditCardType' in base 'creditCard' of base 'localCard' of class 'll'
Error executing cl.exe.

Project.obj - 1 error(s), 3 warning(s)


I don't see any way out of it. I'm badly STUCK.

It seems to be necessary to me to use virtual inheritance. How will you do it without virtual inheritance?
Several problems:
first, virtual inheritance in ll class (and another one)
second, you inherit from all classes in ll, which you should never do. It is mark of bad design which will never work. Container classes should not be inherited from objects they contain. In your case it is better to use std::list for that.
Topic archived. No new replies allowed.