Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Template question problem

Status
Not open for further replies.

grscot

Programmer
Apr 25, 2003
16
GR
Dear all,

I would like to ask if it is possible to have a template function as a general function for two functions that have a different return type.
For example:
int AddNumbers(int a, int b);

float AddFloats(float a, float b);

What would it be the template function for the above example?

Regards,
grscot




 
Well it is questionable why you couldn't just use the + operator, but...

Code:
template<class _T>
_T add(_T a, _T b) {return a+b};

Will
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top