Dear all,
I 've understood that the template function for the two functions :
int AddNumbers(int a, int b);
float AddFloats(float a, float b);
is: template<class T>
T Add(const T &a, const T&b)
{
return a+b;
}
because the arguments' return type is the same as the functions' return type.
But what is the template function when the return type of the arguments is different from the return type of the function?
For example:
Member* get_member(Book* book);
Book* get_book(Member* member);
What is now the template function of the two above functions?
Regards,
grscot
I 've understood that the template function for the two functions :
int AddNumbers(int a, int b);
float AddFloats(float a, float b);
is: template<class T>
T Add(const T &a, const T&b)
{
return a+b;
}
because the arguments' return type is the same as the functions' return type.
But what is the template function when the return type of the arguments is different from the return type of the function?
For example:
Member* get_member(Book* book);
Book* get_book(Member* member);
What is now the template function of the two above functions?
Regards,
grscot