If I apply memory by shared_ptr<double> p(new int);
, the space applied will be automatically released once the use_count
of p
turns to 0. But if I apply for an array memory by shared_ptr<double> p(new int[10]);
, will the whole array memory be released, or only the space of the first value is released(and cause potential memory leak)?
Matrix::Matrix(size_t m, size_t n) {
shared_ptr<double> data_(new double[m * n]);
m_ = m;
n_ = n;
}
Aucun commentaire:
Enregistrer un commentaire