i am struggling with the C++ template concept. What i have is something like that:
abstractClass.h:
namespace a {
namespace b {
template <typename RETURNTYPE, typename DATATYPE>
class AbstractClass {
protected:
RETURNTYPE rtype;
DATATYPE dtype;
std::size_t countValues;
public:
explicit AbstractClass(DATATYPE _dtype, size_t _countValues):
rtype(0),
dtype(_data),
countValues(_countValues) {
}
virtual void process() = 0;
};
} // namespace worker
} // namespace eetneon
derivedClass.h
#include "abstractClass.h"
namespace a {
namespace b {
template <typename RETURNTYPE, typename DATATYPE>
class DerivedClass : public AbstractClass<RETURNTYPE, DATATYPE> {
public:
DerivedClass(DATATYPE _data, size_t _countValues):
AbstractClass<RETURNTYPE, DATATYPE>(_data, _countValues) {
}
void process() override;
};
} // namespace worker
} // namespace eetneon
Now my question is: Is it possible to implement the void process() method within a *.cpp file or do I have to put the implementation in the header file, so the compiler can see it (I read something like that lately), because shit just got real, when i tried to put the implementation stuff away from the *.h file. Are there any sophisticated approaches to solve this problem? Everything i found until now seems a bit rough around the edges!
Thanks for your time and please excuse my horrible english.
Sincerely Hymir