I have such code:
class A
{
public:
A(void);
~A(void)
{
delete b;
delete c;
delete d;
// ...
}
private:
B* b;
C* c;
D* d;
// ...
};
//A.cpp
A(void) : b(new B()), c(new C()), d(new D()) //...
{
}
Class A
takes ownership over own objects b
, c
, d
...
What is the best way to keep these objects? I guess, that usage of std::unique_ptr<B/C/D>
type will be suitable for this way. For example, it allows to don't care about carefull writing of destructor.