I'm having trouble with what is apparently a linker error ("undefined reference") in Eclipse / C++. All the classes shown below compile fine, except for one, PlayGame.cpp, which is giving the "undefined reference" error (also shown below).
Below are the relevant classes and pieces of code.
PlayerFactory.h
PlayerFactory.cpp
Game.h
Game.cpp
// constructor for game:
Game::Game (const PlayerFactory& factory)
{
cout << " constructor" << endl;
}
PlayGame.cpp
// start of code for game where error occurs
#include "Game.h"
#include "PlayerFactory.h"
int main() {
try
{
PlayerFactory factory;
Game game (factory); <== undefined reference error
...
The above line gives the error "undefined reference to `Game(PlayerFactory const&)'"
What's causing this error, and how can it be corrected?