struct B {
int b;
}
struct D {
int * d;
}
class A {
union {
B part1;
D part3;
} parts;
public:
A() {
memset(&parts, 0, sizeof(parts));
}
Now i want rewrite struct D in this way:
struct D {
std::shared_ptr<int> d = nullptr;
}
How should I rewrite constructor and destructor of class A to store it in a vector and use functions as emplace_back()
which needs default constructor?