Unfornately I couldn't find a post regarding my following problem. I want to write a litte class which overloads the <<-Operator to get variable types of data using templates. The .h-file of my class looks like this:
class MyClass {
private:
...
public:
template <typename> void operator<<(T data);
};
The CPP-file:
template <typename T> void MyClass::operator<<(T data) {
...
return;
}
Now I want to use my class:
MyClass mc;
mc << "Test";
mc << 123;
But my gcc compiler won't compile it giving me following error message:
undefined reference to `void MyClass::operator<< <char const*>(char const*)'
or if i use int for example:
undefined reference to `void MyClass::operator<< <int>(int)'
What am I doing wrong??? Can Someone help me?