jeudi 29 octobre 2015

Allocating class member with std::shared_ptr

Is my assumption, that in following example, memory referenced by b will be deallocated once instance of A goes out of scope at end of func(), correct?

class A{
   A() {
        b = std::shared_ptr<char>(new char[100] { 0 } );
   }
private:
 B* b;
}

void func {
   A a;
}

Aucun commentaire:

Enregistrer un commentaire