I have made a function which looks like this:
//hpp
extern std::array<CPlayer, MAX_PLAYERS> PlayerArray;
inline CPlayer& Player(int playerid);
//cpp
std::array<CPlayer, MAX_PLAYERS> PlayerArray;
inline CPlayer& Player(int playerid)
{
return PlayerArray[playerid];
}
but when doing this I get a linker error saying:
error LNK2001: unresolved external symbol "class CPlayer & __cdecl Player(int)" (?Player@@YAAAVCPlayer@@H@Z)
However when I remove the inline
keyword, everything compiles fine.
Why does this happen?