Code:
class CFractal {
public:
virtual void doFractalThing()=0;
CFractal* clone()=0;
};
class CFractalMandel : public CFractal{
public:
virtual void doFractalThing();
CFractal* clone() { return new CFractalMandel(*this); }
// define the copy constructor if need be
private:
// whatever
};
class CFractalJulia : public CFractal{
public:
virtual void doFractalThing();
CFractal* clonse() { return new CFractalJulia(*this); }
// again, define copy constructor if needed
private:
// whatever
};
CFractal* mainFractal;
void onZoomIn() {
CFractal* newFract = mainFractal->clone();
// do whatever, and remember to deallocate newFract when time comes
}
edit: added class inheritance stuff (big missing factor.. sorry )