fork download
  1. #include <iostream>
  2. template <typename T>
  3. int plus(T &a,T &b);
  4. int main()
  5. {
  6. int i=2;
  7. int j=4;
  8. std::cout<< "сумма "<<i<<" и "<<j<<"равна "<<plus(i,j);
  9. return 0;
  10. }
  11. template <typename T>
  12. int plus(T &a,T &b)
  13. {
  14. T temp;
  15. temp=a+b;
  16. return temp;
  17. }
  18.  
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
сумма 2 и 4равна 6