So im just trying to understand a simple program in C++ but i keep getting an error when trying to compile this code. The error is [Linker error] undefined reference to `Player::getHeight()' . So i have my main code in one file called Main.cpp:
#include "Player.h"
int main()
{
Player a;
cout << a.getHeight() << endl;
system("pause");
return 0;
}
then i have my header file in Player.h :
#ifndef PLAYER_H
#define PLAYER_H
#include <iostream>
using namespace std;
class Player
{
public:
Player(){height = 0;};
int getHeight();
private:
int height;
};
#endif
then i have my function file Player.cpp :
#include "Player.h"
int Player::getHeight()
{
return height;
}
Not exactly sure what is going on here, moving things into header files is new to me. Thanks for your time.