user11988: I have written a codebender project which returns this error:
Oops! Looks like there was a serious issue with your project. 

If you are not sure what could be wrong please contact us

/mnt/tmp/compiler.amxHJ9/files/Many Games.o: In function `gamesMaster::gamesMaster()':
Many Games.cpp:(.text._ZN11gamesMasterC2Ev+0xa): undefined reference to `vtable for gamesMaster'
Many Games.cpp:(.text._ZN11gamesMasterC2Ev+0xc): undefined reference to `vtable for gamesMaster' 

What does it mean by vtable?
The code uses basic classes and inheritance.
The program is designed to select and play the game of your choice.  I have only programmed the basic structure.
Class games contains a ref to the class gamesMaster.
Class gamesMaster contains a ref to simpleTimer.
Classes playHiLow and playSimon are children of gamesMaster.
Class games handles and input and outputs, win and lose control and keeps track of lives.
Class gamesMaster handles the simpleTimer, displays a new round, checks for the correct answer, and checks if game has finished successfully.
The main() function runs a routine in the games class.
The code is listed here: https://codebender.cc/sketch:144869
class simpleTimer
{
private:
    unsigned long _previousMillis;
    unsigned long _interval;

public:
    simpleTimer()
    {

    }
    void start(float mins)
    {
        _interval = (unsigned long) (mins * 60 * 1000);
        _previousMillis = millis();
    }
    bool stillRunning()
    {
        return (millis() - _previousMillis < _interval);
    }
};

class gamesMaster
{
public:
    unsigned short lives;
    gamesMaster()
    {
        timeOutTimer = new simpleTimer();
        gameTimer = new simpleTimer();
        gameTimer->start(1.5);
        lives = 5;
    }
    void right()
    {
        Serial.println("Correct");
    }
    void wrong()
    {
        Serial.println("Wrong");
    }
    void winGame()
    {
        Serial.println("**********");
        Serial.println("* WINNER *");
        Serial.println("**********");
    }
    void loseGame()
    {
        Serial.println("\\ /          \\ /");
        Serial.println(" X    LOST    X");
        Serial.println("/ \\          / \\");
    }
    void startTimeOut(float mins)
    {
        timeOutTimer->start(mins);
    }
    bool notTimedOut()
    {
        return timeOutTimer->stillRunning();
    }
    bool gameTimerOver()
    {
        return !gameTimer->stillRunning();
    }
    simpleTimer *timeOutTimer;
    simpleTimer *gameTimer;

    virtual void setupForNewRound(void);
    virtual bool checkAnswer(unsigned short);
    virtual bool reachedEnd(void);
};

class gameHiLow: public gamesMaster
{
public:
    gameHiLow() : gamesMaster() {}
    void setupForNewRound()
    {
        Serial.println("  ->(HiLow) New round");
    }
    bool checkAnswer(unsigned short answer)
    {
        Serial.println("  ->(HiLow) Correct Answer");
        return HIGH;
    }
    bool reachedEnd()
    {
        Serial.println("  ->(HiLow) End of game");
        return HIGH;
    }
};

class gameSimon: public gamesMaster
{
public:
    gameSimon() : gamesMaster() {}
    void setupForNewRound()
    {
        Serial.println("  ->(Simon) New round");
    }
    bool checkAnswer(unsigned short answer)
    {
        Serial.println("  ->(Simon) Correct Answer");
        return HIGH;
    }
    bool reachedEnd()
    {
        Serial.println("  ->(Simon) End of game");
        return HIGH;
    }
};


class games
{
private:
    unsigned short _gameToPlay;
    unsigned short _levelToPlay;
    gamesMaster *myGame;
    unsigned short _getAnswer()
    {
        if (Serial.available() > 0)
        {
            int inByte = Serial.read();
            Serial.println("  ->(games) Decode Answer");

            switch (inByte)
            {
                case '<':
                    return 1;
                    break;
                case '>':
                    return 2;
                    break;
            }

        }
        return 0;

    }
    bool _respond()
    {
        unsigned short answer;
        while(myGame->notTimedOut())
        {
            if((answer = _getAnswer()) != 0)
            {
                if(myGame->checkAnswer(answer) == HIGH) return HIGH;
            }
        }
        return LOW;
    }
public:
    games(unsigned short gameToPlay, unsigned short levelToPlay)
    {
        _gameToPlay = gameToPlay;
        _levelToPlay = levelToPlay;
        switch(_gameToPlay)
        {
            case 1:
                myGame = new gameHiLow();
                Serial.println(" ->(game) play Higher or Lower Game");
                break;
            case 2:
                myGame = new gameSimon();
                Serial.println(" ->(game) play Simon Game");
                break;
        }
    }
    void play()
    {
        unsigned short answer;
        while(!myGame->gameTimerOver())
        {
            myGame->setupForNewRound();
            myGame->startTimeOut(.5);
            if(_respond() == HIGH)
            {
                myGame->right();
                if(myGame->reachedEnd())
                {
                    myGame->winGame();
                    return;
                }
            }
            else
            {
                myGame->wrong();
                if(--myGame->lives <= 0)
                {
                    myGame->loseGame();
                    return;
                }
            }
        }
        myGame->loseGame();
    }
};


//////////////////////////////////////////////////////////////////////////////////
games *game;

void setup()
{
    Serial.begin(9600);
    unsigned short gameToPlay = 1;
    unsigned short levelToPlay = 1;
    game = new games(gameToPlay, levelToPlay);
}

void loop()
{
    Serial.println("Let the games begin");
    game->play();
    Serial.println("Program Complete");
    delay(5000);
    exit(0);
}


user4143: I agree with @GeryOshlike.  But that's not the only option.
Yes, you can make them pure virtual:
virtual void setupForNewRound(void) = 0;
virtual bool checkAnswer(unsigned short) = 0;
virtual bool reachedEnd(void) = 0;

Or you can make them virtual with a default function:
virtual void setupForNewRound(void) { }
virtual bool checkAnswer(unsigned short) { return false; }
virtual bool reachedEnd(void) { return false; }

Pure virtual will complain when you compile if you haven't implemented those functions in your child class.  By providing a default function body it will not complain if you haven't implemented it, and will just use the default body.
If it's a function which you know will always have to be implemented at the child level (will always be different) then go the pure virtual route.  If it's a function that will be the same in a number of children but differ in only a few, then providing the default body and overriding with different ones when needed is the better way to go.

11988: <p>I have written a codebender project which returns this error:</p>

<pre><code>Oops! Looks like there was a serious issue with your project. 

If you are not sure what could be wrong please contact us

/mnt/tmp/compiler.amxHJ9/files/Many Games.o: In function `gamesMaster::gamesMaster()':
Many Games.cpp:(.text._ZN11gamesMasterC2Ev+0xa): undefined reference to `vtable for gamesMaster'
Many Games.cpp:(.text._ZN11gamesMasterC2Ev+0xc): undefined reference to `vtable for gamesMaster' 
</code></pre>

<p>What does it mean by <code>vtable</code>?</p>

<p>The code uses basic classes and inheritance.</p>

<p>The program is designed to select and play the game of your choice.  I have only programmed the basic structure.</p>

<p>Class <code>games</code> contains a ref to the class <code>gamesMaster</code>.</p>

<p>Class <code>gamesMaster</code> contains a ref to <code>simpleTimer</code>.</p>

<p>Classes <code>playHiLow</code> and <code>playSimon</code> are children of <code>gamesMaster</code>.</p>

<p>Class <code>games</code> handles and input and outputs, <code>win</code> and <code>lose</code> control and keeps track of lives.</p>

<p>Class <code>gamesMaster</code> handles the <code>simpleTimer</code>, displays a new round, checks for the correct answer, and checks if game has finished successfully.</p>

<p>The <code>main()</code> function runs a routine in the <code>games</code> class.</p>

<p>The code is listed here: <a href="https://codebender.cc/sketch:144869" rel="nofollow">https://codebender.cc/sketch:144869</a></p>

<pre><code>class simpleTimer
{
private:
    unsigned long _previousMillis;
    unsigned long _interval;

public:
    simpleTimer()
    {

    }
    void start(float mins)
    {
        _interval = (unsigned long) (mins * 60 * 1000);
        _previousMillis = millis();
    }
    bool stillRunning()
    {
        return (millis() - _previousMillis &lt; _interval);
    }
};

class gamesMaster
{
public:
    unsigned short lives;
    gamesMaster()
    {
        timeOutTimer = new simpleTimer();
        gameTimer = new simpleTimer();
        gameTimer-&gt;start(1.5);
        lives = 5;
    }
    void right()
    {
        Serial.println("Correct");
    }
    void wrong()
    {
        Serial.println("Wrong");
    }
    void winGame()
    {
        Serial.println("**********");
        Serial.println("* WINNER *");
        Serial.println("**********");
    }
    void loseGame()
    {
        Serial.println("\\ /          \\ /");
        Serial.println(" X    LOST    X");
        Serial.println("/ \\          / \\");
    }
    void startTimeOut(float mins)
    {
        timeOutTimer-&gt;start(mins);
    }
    bool notTimedOut()
    {
        return timeOutTimer-&gt;stillRunning();
    }
    bool gameTimerOver()
    {
        return !gameTimer-&gt;stillRunning();
    }
    simpleTimer *timeOutTimer;
    simpleTimer *gameTimer;

    virtual void setupForNewRound(void);
    virtual bool checkAnswer(unsigned short);
    virtual bool reachedEnd(void);
};

class gameHiLow: public gamesMaster
{
public:
    gameHiLow() : gamesMaster() {}
    void setupForNewRound()
    {
        Serial.println("  -&gt;(HiLow) New round");
    }
    bool checkAnswer(unsigned short answer)
    {
        Serial.println("  -&gt;(HiLow) Correct Answer");
        return HIGH;
    }
    bool reachedEnd()
    {
        Serial.println("  -&gt;(HiLow) End of game");
        return HIGH;
    }
};

class gameSimon: public gamesMaster
{
public:
    gameSimon() : gamesMaster() {}
    void setupForNewRound()
    {
        Serial.println("  -&gt;(Simon) New round");
    }
    bool checkAnswer(unsigned short answer)
    {
        Serial.println("  -&gt;(Simon) Correct Answer");
        return HIGH;
    }
    bool reachedEnd()
    {
        Serial.println("  -&gt;(Simon) End of game");
        return HIGH;
    }
};


class games
{
private:
    unsigned short _gameToPlay;
    unsigned short _levelToPlay;
    gamesMaster *myGame;
    unsigned short _getAnswer()
    {
        if (Serial.available() &gt; 0)
        {
            int inByte = Serial.read();
            Serial.println("  -&gt;(games) Decode Answer");

            switch (inByte)
            {
                case '&lt;':
                    return 1;
                    break;
                case '&gt;':
                    return 2;
                    break;
            }

        }
        return 0;

    }
    bool _respond()
    {
        unsigned short answer;
        while(myGame-&gt;notTimedOut())
        {
            if((answer = _getAnswer()) != 0)
            {
                if(myGame-&gt;checkAnswer(answer) == HIGH) return HIGH;
            }
        }
        return LOW;
    }
public:
    games(unsigned short gameToPlay, unsigned short levelToPlay)
    {
        _gameToPlay = gameToPlay;
        _levelToPlay = levelToPlay;
        switch(_gameToPlay)
        {
            case 1:
                myGame = new gameHiLow();
                Serial.println(" -&gt;(game) play Higher or Lower Game");
                break;
            case 2:
                myGame = new gameSimon();
                Serial.println(" -&gt;(game) play Simon Game");
                break;
        }
    }
    void play()
    {
        unsigned short answer;
        while(!myGame-&gt;gameTimerOver())
        {
            myGame-&gt;setupForNewRound();
            myGame-&gt;startTimeOut(.5);
            if(_respond() == HIGH)
            {
                myGame-&gt;right();
                if(myGame-&gt;reachedEnd())
                {
                    myGame-&gt;winGame();
                    return;
                }
            }
            else
            {
                myGame-&gt;wrong();
                if(--myGame-&gt;lives &lt;= 0)
                {
                    myGame-&gt;loseGame();
                    return;
                }
            }
        }
        myGame-&gt;loseGame();
    }
};


//////////////////////////////////////////////////////////////////////////////////
games *game;

void setup()
{
    Serial.begin(9600);
    unsigned short gameToPlay = 1;
    unsigned short levelToPlay = 1;
    game = new games(gameToPlay, levelToPlay);
}

void loop()
{
    Serial.println("Let the games begin");
    game-&gt;play();
    Serial.println("Program Complete");
    delay(5000);
    exit(0);
}
</code></pre>
 4143: <p>I agree with @GeryOshlike.  But that's not the only option.</p>

<p>Yes, you can make them <em>pure virtual</em>:</p>

<pre><code>virtual void setupForNewRound(void) = 0;
virtual bool checkAnswer(unsigned short) = 0;
virtual bool reachedEnd(void) = 0;
</code></pre>

<p>Or you can make them virtual with a default function:</p>

<pre><code>virtual void setupForNewRound(void) { }
virtual bool checkAnswer(unsigned short) { return false; }
virtual bool reachedEnd(void) { return false; }
</code></pre>

<p>Pure virtual will complain when you compile if you haven't implemented those functions in your child class.  By providing a default function body it will not complain if you haven't implemented it, and will just use the default body.</p>

<p>If it's a function which you know will always have to be implemented at the child level (will always be different) then go the pure virtual route.  If it's a function that will be the same in a number of children but differ in only a few, then providing the default body and overriding with different ones when needed is the better way to go.</p>
