cpp_prac/junk/1.5.cc
2025-01-10 08:15:31 +01:00

27 lines
350 B
C++

#include <iostream>
using std::cout;
struct A {
A() = default;
A(int x) { val = x; }
void print() { cout << "A(" << val << ")"; }
int val;
};
struct B {
// B(int x) { a = A(x); }
B(int x) : a(x) {}
void print() {
cout << "B(";
a.print();
cout << ")";
}
A a;
};
int main() {
B b(10);
b.print();
cout << "\n";
}