Probably a Beginner-mistake so be merciful with me.
I want to access Game.cpp through Game.hpp. But main.cpp seemingly isn't allowing that.
// game.cpp
#include "Game.hpp"
bool loadConfig(std::string config_file)
{
//does stuff
}
void run()
{
// does stuff
}
//game.hpp
#include "Interface.hpp"
namespace Oop
{
class Game
{
private:
Interface& io_;
public:
Game(Interface &io);
bool loadConfig(std::string config_file);
void run();
};
inline Game::Game(Interface &io): io_(io) {};
}
//main.cpp
#include "Interface.hpp"
#include "Game.hpp"
int main()
{
std::string config_file = "config01.json";
Oop::Interface io;
Oop::Game game(io);
if (!game.loadConfig(config_file))
{
return Oop::RETURN_ERROR_BAD_CONFIG;
}
game.run();
}
I've shortened the code so that you can better see what's going on. I know Interface is missing but I don't think it has something to do with the error.
I get the Error message:
- Undefined reference to Oop::Game::loadConfig(...)
- Undefined reference to Oop::Game::run()
What's the problem?
Thanks in advance.