| 1 | struct A { |
|---|---|
| 2 | int i = 47; |
| 3 | int f() { return i; } |
| 4 | virtual ~A() = default; |
| 5 | }; |
| 6 | |
| 7 | struct B: public A { |
| 8 | int j = 42; |
| 9 | }; |
| 10 | |
| 11 | namespace ns { |
| 12 | struct A { |
| 13 | int i = 147; |
| 14 | ::A getA(); |
| 15 | A(); |
| 16 | }; |
| 17 | A::A() = default; |
| 18 | |
| 19 | ::A A::getA() { |
| 20 | ::A a; |
| 21 | a.i = i - 1; |
| 22 | return a; |
| 23 | } |
| 24 | |
| 25 | } // namespace ns |
| 26 | |
| 27 | int foo(A *a) { |
| 28 | return a->f(); |
| 29 | } |
| 30 | |
| 31 | int main() { |
| 32 | return foo(a: new B); |
| 33 | } |
| 34 |
