Answers for "unique_ptr syntax"

C++
0

unique_ptr syntax

unique_ptr<A> ptr1 (new A);
// Error: can't copy unique_ptr
 unique_ptr<A> ptr2 = ptr1; 
 // Works, resource now stored in ptr2
unique_ptr<A> ptr2 = move(ptr1);
Posted by: Guest on September-23-2021

Browse Popular Code Answers by Language