This question already has an answer here:
ALL,
There are plenty of examples on the web about using smart pointers with one level of indirection. I.e.:
char *p = new char;
unique_ptr<char> p;
p = std::make_unique<char>();
Those 3 lines above are the same - one is using old style pointer with new the other 2 are using C++11 smart-pointer.
However, I wasn't able to find an example on how to convert (what should be the syntax) for
char **p;
p = new char*;
p[0] = new char[15];
Is going to be
unique_ptr<unique_ptr<char> > p;
auto temp = std::make_unique<char>();
p = std::make_unique<>( p );
Could someone please help?
TIA!
Aucun commentaire:
Enregistrer un commentaire