SVC
2008-07-18 21:38:23 UTC
Hi,
It is always possible to declare an inline template function within a class.
Is it possible to have a non-inline template function within a class?
How do we call it?
For example:
in Header file
--------------
class TMyClass
{
public:
template <class T> bool MyFunc(T a, T b) ;
};
extern TMyClass MyClass;
In Cpp file
----------
TMyClass MyClass;
//..
//...
template <class T> bool MyClass::MyFunc(T a, T b)
{
// ... do stuff
return true;
}
In another Cpp, file
-------------------
How do we call this member function?
MyClass.MyFunc<int>(i,j); // does not work (compiler error)
MyClass.template<int>MyFunc(i,j); // does not work (compiler error)
Thanks,
S
It is always possible to declare an inline template function within a class.
Is it possible to have a non-inline template function within a class?
How do we call it?
For example:
in Header file
--------------
class TMyClass
{
public:
template <class T> bool MyFunc(T a, T b) ;
};
extern TMyClass MyClass;
In Cpp file
----------
TMyClass MyClass;
//..
//...
template <class T> bool MyClass::MyFunc(T a, T b)
{
// ... do stuff
return true;
}
In another Cpp, file
-------------------
How do we call this member function?
MyClass.MyFunc<int>(i,j); // does not work (compiler error)
MyClass.template<int>MyFunc(i,j); // does not work (compiler error)
Thanks,
S