for a personal project i need to define a template class for a better optimization.
I have followed exemple, but it doesn't compile yet cause i want my template class inherit from an interface. Can someone tell me how to use it, here is my code :
My dot HPP
template<typename T>
class Container : public IOP
{
public:
Container();
T val;
int getpr() const;
IOP *operator+(const IOP &r) const;
IOP *operator-(const IOP &r) const;
IOP *operator*(const IOP &r) const;
IOP *operator/(const IOP &r) const;
}
My dot cpp where there is my functions (constructor ...)
Container::Container()
{
}
int Container::getpr()
{
...
}
... etc
And i want to use my class like that :
Container<long> test;
or
Container<int> test;
Thanks for any help, link or explanation.
compilation error for the moment :
Container.cpp:13:1: error: expected a class or namespace
Container::Container()
^
Container.cpp:13:12: error: C++ requires a type specifier for all declarations
Container::Container()
~~~~~~~~~ ^
Container.cpp:24:20: error: expected a class or namespace
std::string const &Container::toString()
^
Container.cpp:29:5: error: expected a class or namespace
int Container::getPrecision
()