Код: Выделить всё
class B;
class A
{
private:
list myList;
unique_ptr smartUniq;
public:
A()
{
myList.push_back(new B(5));
myList.push_back(new B(6));
myList.push_back(new B(7));
}
~A()
{
for (auto& item : myList)
{
delete item;
}
cout getb()));
}
smartUniq.reset(src.smartUniq.get() ? make_unique(*src.smartUniq) : nullptr);
}
return *this;
}
};
- Что это за утилита удалить текущих участников перед копированием?
- какая польза от : if( this != &src)?
Подробнее здесь: https://stackoverflow.com/questions/791 ... ent-method