jeudi 5 février 2015

How to assign address of a int variable to unique_ptr

This is the code.



int main()
{
unique_ptr <int> p {nullptr};
int val = 100;
p = &val; // Not working - compilation error
p = move(&val); // Not working - compilation error
cout << *p;
return 0;

}


What is the correct way?


Aucun commentaire:

Enregistrer un commentaire