I have a C++ project in VS 2015. I created a template function in one class.
TressPos.h
class TressPos
{
//constructor
//destructor
template <typename T>
void GetNewVector(T* t, int scale);
}
TressPos.cpp
template <typename T>
void TressPos::GetNewVector(T* t, int scale)
{
//Do somethings here..
//....................
}
Now in another class.
DigitalMaster.cpp
TressPos tp;
void DigitalMaster::NesterLock()
{
tp.GetNewVector(this, 1200);
//More todo's here...
//................
tp.GetNewVector(.....);
}
Now when i build the project, it's giving an linker error.
Basically complaining that the GetNewVector can't accept a pointer to DigitalMaster as the 1st argument.
So what i did was to move the template function as inline in TressPos class.
TressPos.h
class TressPos
{
//constructor
//destructor
template <typename T>
inline void TressPos::GetNewVector(T* t, int scale)
{
//Do somethings here..
//....................
}
}
Now i don't get any linker error when i call this template function in DigitalMaster class.
But for some reason, visual studio thinks there's no function called in GetNewVector in TressPos class. Even though both compiler and linker are happy.
i.e., in visual stuido editor, it draws a red line below the GetNewVector fuction in DigitalMaster.cpp file.
Any ideas what's happening? Am new to using templates in C++.