#Unique pointers
9 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
@sour trench
Your message appears to contain screenshots but no code. Please send code and error messages in text instead of screenshots if applicable!
say i want another thing to point to 42 now
do i add that inside the takeownership func
on the line with TakeOwnership(std::move(Number)); you transfer ownership of the "integer 42" from Number to the function parameter Num
that means Number owns nothing and points to nothing, whereas Num points to the "integer 42" and owns it
then when the function oTakeOwnership completes, Num is destroyed and takes down the "integer 42" it owned with it
the final line std::cout << *Number; is not a valid construct because you're cannot validly use * on a unique pointer that owns nothing
!solved