← All topics
Quiz: Memory and Smart Pointers: questions with answers
10 questions, each with the answer and a short explanation.
Take the timed quiz + get a certificate →- Q1. Which smart pointer should be your default choice?
- Q2. What happens when you try to copy a uniqueptr?
- Q3. Which correctly frees memory from new int[50]?
- Q4. What does RAII guarantee?
- Q5. What does this print? (code)
- Q6. What does this print? (code)
- Q7. How do you hand ownership from one uniqueptr to another?
- Q8. Two objects hold sharedptrs to each other. What goes wrong?
- Q9. Why prefer makeunique<Student() over uniqueptr<Student(new Student())?
- Q10. Which exception does vector::at(i) throw when i is outside the vector?