#include #include using namespace std; class window { //grandparent int i; public: window(int initial_i): i(initial_i) { cout << "construct window " << i << "\n"; } ~window() {cout << "destruct window " << i << "\n";} }; class window_with_horizontal: public virtual window { //mother int j; public: window_with_horizontal(int initial_i, int initial_j) : window(initial_i), j(initial_j) { cout << "construct window_with_horizontal " << initial_i << " " << initial_j << "\n"; } ~window_with_horizontal() { cout << "destruct window_with_horizontal " << j << "\n"; } }; class window_with_vertical: public virtual window { //father int k; public: window_with_vertical(int initial_i, int initial_k) : window(initial_i), k(initial_k) { cout << "construct window_with_vertical " << initial_i << " " << initial_k << "\n"; } ~window_with_vertical() { cout << "destruct window_with_vertical " << k << "\n"; } }; class window_with_horizontal_and_vertical: //grandchild public window_with_horizontal, public window_with_vertical { int l; public: window_with_horizontal_and_vertical(int initial_i, int initial_j, int initial_k, int initial_l) : window(initial_i), window_with_horizontal(initial_i, initial_j), window_with_vertical(initial_i, initial_k), l(initial_l) { cout << "construct window_with_horizontal_and_vertical " << initial_i << " " << initial_j << " " << initial_k << " " << initial_l << "\n"; } ~window_with_horizontal_and_vertical() { cout << "destruct window_with_horizontal_and_vertical " << l << "\n"; } }; int main() { window_with_horizontal_and_vertical w(10, 20, 30, 40); cout << "\n"; return EXIT_SUCCESS; }