Question

Question: Use weak_ptr for shared_ptr like pointers that can dangle. int main{ shared_ptr name2(new Name2(“Donald Duck”));...

Question: Use weak_ptr for shared_ptr like pointers that can dangle.

int main{

shared_ptr name2(new Name2(“Donald Duck”));

delete name2;

weak_ptr name3= move(name2);

return 0;

}

does this work for the question? Can you also give me another example if I'm wrong

Using C++ Visual Studio

0 0
Add a comment Improve this question Transcribed image text
Answer #1

the code provided is possible in c++ as name2 is a value or string but we are directly using the name2 and moving it into name3 which is part of pointer weak_ptr .

Add a comment
Know the answer?
Add Answer to:
Question: Use weak_ptr for shared_ptr like pointers that can dangle. int main{ shared_ptr name2(new Name2(“Donald Duck”));...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT