K
KK
Hello all,
I'm sure this must be a simple matter of language syntax, but could
not find an appropriate reference so I'm posting the question here.
Consider
template < class T = double >
class Example
{
T _val;
//define constructor & destructor
void Init ( int a );
}
template <class T > //do this if T is of type double, int, unsigned
void Init (int a)
{
_val = T(a);
}
so far it is fine ... I would like to overload function 'Init' when the
'T' is type 'float' with something like
template <class T >
void InitFloat (int a)
{
_val = T (a+1);
}
how can I achieve both functions exist with same function name?
Thank you
-KK
I'm sure this must be a simple matter of language syntax, but could
not find an appropriate reference so I'm posting the question here.
Consider
template < class T = double >
class Example
{
T _val;
//define constructor & destructor
void Init ( int a );
}
template <class T > //do this if T is of type double, int, unsigned
void Init (int a)
{
_val = T(a);
}
so far it is fine ... I would like to overload function 'Init' when the
'T' is type 'float' with something like
template <class T >
void InitFloat (int a)
{
_val = T (a+1);
}
how can I achieve both functions exist with same function name?
Thank you
-KK