December 2001
Intermediate to advanced
304 pages
6h 25m
English
ValuePtrDifficulty: 6
Can we make life safer for ourselves and our users by devising a smart pointer class designed specifically for class membership?
Write a suitable ValuePtr template that is used as shown here:
// Example 31-1
//
class X
{
// ...
private:
ValuePtr<Y> y_;
};
to suit three specific circumstances:
Copying and assigning ValuePtrs is not allowed.
Copying and assigning ValuePtrs is allowed and has the semantics of creating a copy of the owned Y object using the Y copy constructor.
Copying and assigning ValuePtrs is allowed and has the semantics of creating a copy of the owned Y object, which is performed using a virtual Y::Clone() method if present and the Y copy constructor otherwise. ...
Read now
Unlock full access