about sington patten
w_j76 2002-07-09 02:51:07 please watch the sample about sington patten
class MazeFactory {
public:
static MazeFactory* Instance();
protected:
MazeFactory();
~ MazeFactory();
private:
static MazeFactory* _instance;
};
The corresponding implementation is
MazeFactory* MazeFactory::_instance = 0;
MazeFactory* MazeFactory::Instance () {
if (_instance == 0) {
_instance = new MazeFactory;
}
return _instance;
}
client call this class like this
MazeFactory * mazeclient=MazeFactory::Instance();
please notice there is a new but not delete ,
why it not cause memory leak?