CJCoding With Joseph

Diamond Problem With Virtual Inheritance

When two classes inherit from the same base and a fourth class inherits from both, you get the "diamond problem": two copies of the base and ambiguous member access. virtual inheritance fixes this by keeping a SINGLE shared base subobject.

Person (already written) has string role() const returning "person".

Create Student and Employee that each inherit from Person using VIRTUAL inheritance, and TeachingAssistant that inherits from both Student and Employee.

Because of virtual inheritance, role() on a TeachingAssistant is unambiguous. The program prints:
person

Do NOT write a main function.

Expected Output:

person
Topics:
Inheritance
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.