fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. template <typename T>
  6. T findSum(T a, T b) {
  7. return a + b;
  8. }
  9.  
  10. int main() {
  11. cout << findSum(10, 15) << endl; // 25
  12. cout << findSum(5.7, 3.2) << endl; // 8.9
  13.  
  14. string s1 = "ab";
  15. string s2 = "cd";
  16. cout << findSum(s1, s2) << endl; // abcd
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
25
8.9
abcd