jeudi 26 septembre 2019

Correct way to initialize and assign a shared Pointer

This is the way i am initializing a shared pointer.

std::shared_ptr<ClassA> ClassA::Clone() const
{
    ClassA* smt = new ClassA(*this);
    return std::shared_ptr<ClassA>(smt);
}

Is this the correct way to assign a shared pointer.

Aucun commentaire:

Enregistrer un commentaire