G
Guest
Hi I am trying to learn how to set up and use generic functions (can operate on different data types). I have a simple function to add any type, set up a
//template function to add any 2 types togethe
template<class T
T Addition(T first,T second
T tempvar
tempvar=first + second
return (tempvar)
I am trying to use it by adding 2 float types
double rsum
rsum = Addition(2.2,3.3);//call generic function, but get error C3861, Addition adentifier not found. I do not have
delcaration yet so think this is the problem. What would be the proper declaration-or prototype if I want this as a global function, ie not part of a class? Thanks Paul.
//template function to add any 2 types togethe
template<class T
T Addition(T first,T second
T tempvar
tempvar=first + second
return (tempvar)
I am trying to use it by adding 2 float types
double rsum
rsum = Addition(2.2,3.3);//call generic function, but get error C3861, Addition adentifier not found. I do not have
delcaration yet so think this is the problem. What would be the proper declaration-or prototype if I want this as a global function, ie not part of a class? Thanks Paul.