dimanche 31 mai 2020

Returning smart pointer from raw pointer

This is the way i am returning smart pointer from a raw pointer.

std::shared_ptr<Geometry> Clone() const
{
    Circle *sc = new Circle(*this);
    return std::shared_ptr< Geometry >(sc);
}

Is it the correct way to return Smart pointer from raw pointer ?

Aucun commentaire:

Enregistrer un commentaire