111
|
1 // { dg-do run }
|
|
2 // { dg-options "" }
|
|
3
|
|
4 #include <iostream>
|
|
5
|
|
6 class foo {
|
|
7 public:
|
|
8 foo(int i) {k = i;}
|
|
9 protected:
|
|
10 int k;
|
|
11 };
|
|
12
|
|
13 class bar_1 : public foo {
|
|
14 public:
|
|
15 bar_1(int i) : foo(i) {}
|
|
16 int get_k() {return k;}
|
|
17 };
|
|
18
|
|
19 class bar_2 : public foo {
|
|
20 public:
|
|
21 bar_2(int i) : foo(i) {}
|
|
22 int get_k() {return k;}
|
|
23 };
|
|
24
|
|
25 class multiple : public bar_1, public bar_2 {
|
|
26 public:
|
|
27 multiple(int i1, int i2) : bar_1(i1), bar_2(i2) {}
|
|
28 void print() {
|
|
29 std::cout << "bar_1::k -> " << bar_1::k << "\n";
|
|
30 std::cout << "bar_2::k -> " << bar_2::k << "\n";
|
|
31 std::cout << "bar_1::get_k() -> " << bar_1::get_k() << "\n";
|
|
32 std::cout << "bar_2::get_k() -> " << bar_2::get_k() << "\n";
|
|
33 }
|
|
34 };
|
|
35
|
|
36 int main() {
|
|
37 multiple m(1,2);
|
|
38 m.print();
|
|
39 }
|
|
40
|
|
41
|