Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
Difficulty: 1/10
Date added: 30th of March 2011
This exercise shows that working with smart pointers is not always easy...
This exercise is a continuation on Exercise #1: A foolproof function.
Following Exercise #1: A foolproof function a programmer has written the following class:
#include <boost/checked_delete.hpp> |
Writing such a class enables safe forward declarations and forces the user of this class to use smart pointers, which is a good thing [1].
This programmer wants to use a class managing a boost::shared_ptr of MyStruct, but he/she also wants to let the user obtain a read-only smart pointer/pointer.
The code below shows the choices and some lines that should and should not compile:
struct MyStructKeeper |
What should the question marks be?
View the answer of this part of the exercise
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.