"undefined reference to" Error compiling c ++

0

Hello I did a project as a practice in visual studio code, but when trying to compile I get an error

C:\Users\User\AppData\Local\Temp\cc3apBod.o: In function 'main':
G:\Hangman\HangMan/main.cpp:7: undefined reference to 
'GameModeHangMan::GameModeHangMan()'
collect2.exe: error: ld returned 1 exit status
The terminal process terminated with exit code: 1

I attach the files:

at: GameModeHangMan.h

#include <iostream>

class GameModeHangMan
{
public:
    GameModeHangMan();
    void saludo();
};

at: GameModeHangMan.cpp

#include "GameModeHangMan.h"
#include <iostream>

GameModeHangMan::GameModeHangMan()
{
    saludo();
}

void GameModeHangMan::saludo()
{
    std::cout<<"Hola";
};

Finally in: main.cpp

#include "GameModeHangMan.h"
#include <time.h>

int main()
{
    GameModeHangMan HMGame;

    HMGame.saludo();
    system("Pause");
    return 0;
}

I send it to compile from console with:     g ++ -std = c ++ 11 -g main.cpp

Thanks for the help

    
asked by Jorge Morales 11.09.2018 в 19:57
source

0 answers