int main()
{
//instruction 1 -> OK
std::unique_ptr<int[]> sp2(new int[10]);
//instruction 2 ->error does not compile
std::shared_ptr<int[]> sp1(new int[10]);
}
I was reading about delete and delete[] when memory allocated for smart pointers is with new[]. Why instruction 1 with std::unique_ptr
is ok and with std::shared_ptr
isn't ?
Aucun commentaire:
Enregistrer un commentaire