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