Next: clone()
Up: The Strategy Pattern
Previous: The Strategy Pattern
Consider:
class NearestNeighbour
{
private:
DistanceBase* _d;
public:
NearestNeighbour(DistanceBase& d) : _d(&d) {}
...
- This uses a pointer to the external DistanceBase object
- The external object must be in scope at all times
- Nasty.
- There is an elegant solution: clone()
Tim Cootes
2/24/1998