I have an interface and a couple of implementations of a class that stores serialized objects. I'd like to make the implementation classes into template classes so I can use them with more than one type of object, but I'm getting compiler errors.
#include <iostream>
template<typename T>
class Interface{
public:
virtual void func(T& c) = 0;
};
class Container{
public:
Container() : dummy(10){}
int dummy;
};
template<typename T>
class Implementation : public Interface{
public:
void func(T& c){
std::cout << "++c.dummy " << ++c.dummy << std::endl;
}
};
int main(){
Container c;
Implementation<Container> i;
i.func(c);
return 0;
}
I get "error: expected class-name before ‘{’ token" at the "class Implementation..." line.
Thanks.