Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in --d --h --m --s-- days -- hours -- minutes -- seconds.
Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 07m 39s1 days 16 hours 7 minutes 39 seconds.
Guide: Optiver Interview Questions: The Process, the Games and How to Prepare · C++ Interview Questions for HFT and Quant Developer Roles
You are reviewing a colleague's game-engine code where maze elements are created dynamically. Identify the design pattern used below.
class MapSite {
public:
virtual MapSite* clone() const = 0;
virtual ~MapSite() = default;
};
class Room : public MapSite {
public:
Room* clone() const override { return new Room(*this); }
};
class Maze {
public:
virtual Maze* clone() const { return new Maze(*this); }
virtual ~Maze() = default;
};
class MazeFactory {
public:
MazeFactory(Maze* m, Room* r) : mazeProto(m), roomProto(r) {}
Maze* makeMaze() const { return mazeProto->clone(); }
Room* makeRoom() const { return roomProto->clone(); }
private:
Maze* mazeProto;
Room* roomProto;
};