Solved
template problem
Posted on 1998-09-03
Hi All,
Why does the following code not function.
Microsoft Visual C++ 5.00
// Header File
class Math {
public:
// ... (Constructors destructors etc.... )
template< class T > T Min( T a, T b );
};
// CPP File
template< class T > T Math::Min( T a, T b )
{
return (a < b) ? a : b;
}
This will not link when the code above is entered.
The odd thing about this little caveat is that the following code
WILL work.
// (All in header file)
class Math {
public:
// ... (Constructors destructors etc.... )
template< class T > T Min( T a, T b ) { return (a < b) ? a : b ; };
};
If anyone can convincingly explain why this is the case, the points are yours...
A workaround or something (perhaps namespaces are required???) would be appreciated.
Kind Regards
-craig and sean.