Sobes.tech
Junior — Senior

Virtual inheritance to solve the diamond access problem

livecode

Task condition

It is necessary to demonstrate the use of virtual inheritance, which allows eliminating ambiguity when accessing members of the base class in the case of a diamond hierarchy.

struct A {
    int h;
};

struct B : virtual A { };

struct C : virtual A { };

struct D : B, C { };