Why
struct X{};
X x;
X *q = &x;
std::shared_ptr<X> p(&x);
causes error and
X x;
X *q = &x;
std::shared_ptr<X> p0 = std::make_shared<X>(x);
doesn't cause runtime error?
I read that in the first case I have "two different pointers, pointing to the same data and one of them is shared"
But I think that there is the same situation in the second case?
runtime error
free(): invalid pointer
Aucun commentaire:
Enregistrer un commentaire