I have the existing code like this, how to convert it to use shared_ptr without using new/delete ?
B *ptr1;
C *ptr2;
// two constructor of class A
A::A():ptr1(nullptr), ptr2(nullptr) {}
A::A(std::istream *a) {
ptr1 = new B(a);
ptr2 = new C(*ptr1, *(this));
}
A::~A() {
delete ptr1;
delete ptr2;
}
Aucun commentaire:
Enregistrer un commentaire