2025-01-10 08:15:31 +01:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
using std::cout;
|
|
|
|
|
|
|
|
struct A {
|
2025-01-11 17:54:29 +01:00
|
|
|
A() = default;
|
|
|
|
A(int x) { val = x; }
|
|
|
|
void print() { cout << "A(" << val << ")"; }
|
|
|
|
int val;
|
2025-01-10 08:15:31 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct B {
|
2025-01-11 17:54:29 +01:00
|
|
|
// B(int x) { a = A(x); }
|
|
|
|
B(int x) : a(x) {}
|
|
|
|
void print() {
|
|
|
|
cout << "B(";
|
|
|
|
a.print();
|
|
|
|
cout << ")";
|
|
|
|
}
|
|
|
|
A a;
|
2025-01-10 08:15:31 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
int main() {
|
2025-01-11 17:54:29 +01:00
|
|
|
B b(10);
|
|
|
|
b.print();
|
|
|
|
cout << "\n";
|
2025-01-10 08:15:31 +01:00
|
|
|
}
|