#include <iostream>
struct V {
int x;
V(int t) : x(t) {}
};
struct A : virtual V {
int x;
A(int t) : V(3 * t), x(3 * t) {}
};
struct B : virtual V {
int x;
B(int t) : V(5 * t), x(5 * t) {}
};
struct C : A, B {
C(int t) : V(t), A(t), B(t) {}
void show_x() {
std::cout << "V::x = " << V::x << std::endl;
}
};
int main() {
C c(1);
c.show_x();
return 0;
}
Login in to like
Login in to comment