Код
#include
#include [*]
#include
using namespace std;
class B
{
int b;
public:
B(){};
B(int _b)
{
b = _b;
}
int getb() const {return b;}
void setb(int _b) {b=_b;}
};
class A
{
private:
list myList;
B isb;
unique_ptr smartUniq;
shared_ptr smartShared;
public:
A(): isb(10), smartUniq(make_unique(20))
{
myList.push_back(new B(5));
myList.push_back(new B(6));
myList.push_back(new B(7));
int x=30;
smartShared = make_shared(x);
}
~A()
{
for (auto& item : myList)
{
delete item;
}
cout
Подробнее здесь: https://stackoverflow.com/questions/791 ... e-same-dat
Мобильная версия