I have this:
template<typename T>
class GameDatabase {
public:
GameDatabase(PreparedStatement<T>* preparedStatement,GameDatabaseFlags gdf)
{
_preparedStatement = preparedStatement;
_gameObjectDatabaseFlag = gdf;
}
GameDatabaseFlags _gameObjectDatabaseFlag;
virtual void MapGameDatabaseContainer(GameDatabaseContainer gameDatabaseContainer) = 0;
protected:
uint32_t versionId;
PreparedStatement<T>* _preparedStatement;
};
Than I have my derived class GameObjectsDatabase.h
:
template<typename T>
class GameObjectsDatabase : public GameDatabase<T> {
public:
GameObjectsDatabase(PreparedStatement<T>* preparedStatement,GameDatabaseFlags gdf) : GameDatabase<T>(preparedStatement, gdf) {}
void MapGameDatabaseContainer(GameDatabaseContainer gameDatabaseContainer);
};
template<typename T>
void GameObjectsDatabase<T>::MapGameDatabaseContainer(GameDatabaseContainer gameDatabaseContainer) {
}
As you can see the declaration of MapGameDatabaseContainer
is made in the header file and the program compiles.
If I take this:
template<typename T>
void GameObjectsDatabase<T>::MapGameDatabaseContainer(GameDatabaseContainer gameDatabaseContainer) {
}
Out of GameObjectsDatabase.h
and place it in GameObjectsDatabase.cpp
I get this error:
Undefined symbols for architecture arm64:
"__ZN19GameObjectsDatabaseI23WorldDatabaseConnectionE24MapGameDatabaseContainerE21GameDatabaseContainer", referenced from:
__ZTV19GameObjectsDatabaseI23WorldDatabaseConnectionE in GameDatabaseLoader.cpp.o
ld: symbol(s) not found for architecture arm64
collect2: error: ld returned 1 exit status
make[3]: *** [bin/lib/libCommon.dylib] Error 1
make[2]: *** [Source/Common/CMakeFiles/Common.dir/all] Error 2
make[1]: *** [Source/WorldServer/CMakeFiles/WorldServer.dir/rule] Error 2
make: *** [WorldServer] Error 2
Why is that? Why I can't declare it outside of the header file ?