
9 Oct
2007
9 Oct
'07
9:38 p.m.
Steven wrote:
Suppose that I want to write template<class Rectangle, class T> void move_up(Rectangle&, T offset); to modify a rectangle in place. if I need to copy the rectangle this isn't going to work.
You don't need to copy the rectangle. It does work. Inheritance and composition are just syntactical ways that I can view your data as a rectangle of my type in place. The whole point of my design pattern is that you don't need to copy the rectangle. mimic doesn't copy, it returns a reference to your object of the subclass type with a (safe) reinterpret_cast. Luke