dimanche 10 novembre 2019

Why is this shown as error and what is it supposed to be?

It's part of a game. The game reads the map file and now the map has to be implemented in singleton design pattern. if() is shown as error in compiler. I have the code below:

//.h
class Map
{
    static Map* m_instance;
public:
    static Map* getInstance();
    Map();
    ~Map();

//.cpp
static Map *getInstance()
{
    if (!m_instance)
        m_instance = new Map();
    return m_instance;
}

Aucun commentaire:

Enregistrer un commentaire