I know that you cannot templatize a virtual function and I do understand the concept behind it. But I still need a way to get past some errors I am getting. I am able to make my stuff work, but it doesn't look right to me.
I have class called System
:
#include "Vector.h"
class System
{
virtual void VectorToLocal(Vector<T>& global_dir,const Vector<T>* global_pos = 0) const = 0;
};
class UnresolvedSystem : public System
{
virtual void VectorToLocal(Vector<T>& global_dir,const Vector<T>* global_pos = 0) const
{
//do something
}
};
In Vector.h
:
tenplate<typename T>
class Vector
{
//some functions
};
Now I want to templatize VectorToLocal
in system.h
to take just Vector<T>
, but I cannot do it, since it is a virtual function. I want a work-around. I know I can have VectorToLocal
take Vector<float>
, Vector<double>
, etc., as arguments, but I do not want to do it.