I am currently working in Ubuntu9.10 - c++. I need to define an generic object in a method. I have to define the method in .h file. How can I do it? I did the following:
file.h
class ana
{
//code
public:
template <class T> bool method (T &Data);
};
file.cpp
//code
template <class T>
bool ana::method(T &Data)
{
//code
}
I've created the .a file.
In test.cpp:
//code
main()
{
//code
Ana* ann = new Ana();
if (ann->method(*ann)){//code}
}
After compiling with g++ test.cpp -o test libfile.a I have the error: undefined reference to bool.... Why? Is there another way to create a generic object?