As title. Here is the problem (assume functions and classes Item and WriteBin are already defined, and work properly (they do).
in main.cpp
main()
{
Item item;
item( "ITEM_LONGBOW", "Longbow", "A stout longbow of yew and ash. Fires long arrows, suitable for hunting or warfare.", 6 );
WriteObject( item, "ITEM_LONGBOW.RIF");
return 0;
}
in function.h
#ifndef FUNCTION_H
#define FUNCTION_H
#include "other_functions.h"
#include <fstream>
template<class A>
bool WriteObject( A & object, std::string filename );
#endif
in function.cpp
#ifndef FUNCTION_CPP
#define FUNCTION_CPP
#include "function.h"
template<class A>
bool WriteObject( A & object, std::string filename )
{
std::ofstream fout ( filename.c_str(), std::ofstream::binary );
if (!fout )
return false;
for ( unsigned i = 0; i < object.NumberMember(); ++i )
WriteBin( (char*)&object.AccessMember(i), object.Size(i) );
fout.close();
}
#endif
It gives me this error:
in function 'main':
[Linker error] undefined reference to `bool WriteObject<Item>(Item&, std::string)'
How come? Thanks!