I have a class called File with the following method:
Code:
template <class T>
bool File::writeBytes(T *obj)
{
if(fwrite(obj, sizeof(T), 1, file) < 1)
return false;
return true;
}
I call the method as follows:
Code:
class foo
{
public:
int a;
string b;
};
...
File file("test");
foo f;
f.a = 4545;
f.b = "32453452354";
file3.writeBytes(&f);
But I get the following error when compiling:
/usr/people/cs/student/ymalik/axesone/main.cc:30: undefined reference to `bool File::writeBytes<foo>(foo*)'
But I do have it since the method is templated. Can someone please tell me what is wrong?
Thanks.