0

wap to find sum and average of two number using template function

please help me to do it faster

21st Sep 2018, 5:57 AM
lahi Ur
lahi Ur - avatar
3 Respostas
+ 1
#include <iostream> using namespace std; template <class T, class U> T sum(T a, U b) { return (a+b); } int main() { cout<<"sum :-"<<sum(5,3)<<endl; cout<<"ave :-"<<sum(5,3)/2<<endl; } https://code.sololearn.com/cUIFqIp7PASh/?ref=app
21st Sep 2018, 6:19 AM
estifanos
estifanos - avatar
0
https://www.programtopia.net/cplusplus/docs/templates
21st Sep 2018, 6:06 AM
deepak sharma
deepak sharma - avatar
0
estifanos tekiea i said using template function not template class
21st Sep 2018, 8:02 AM
lahi Ur
lahi Ur - avatar