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