I have the following code:
class Thing
{};
void fnc(Thing** out)
{
*out = new Thing();
};
Where fnc returns a new instance of Thing via output parameter. Normally I'd use it as follows:
int main()
{
Thing* thing;
fnc(&thing);
}
Can I put the returned object in a std::unique_ptr instead?
int main()
{
std::unique_ptr<Thing> uniqueThing;
fnc(???);
}
Aucun commentaire:
Enregistrer un commentaire