fork download
  1. //templates what gets printed
  2.  
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. template <class T1, class T2>
  8.  
  9. int mystery(T1& a, T2 b, int c)
  10.  
  11. {
  12.  
  13. T1 t = a;
  14.  
  15. a = a + b;
  16.  
  17. return ( a - t + c);
  18.  
  19. }
  20.  
  21. int main(void)
  22.  
  23. {
  24.  
  25. int a = 3;
  26.  
  27. double b = 2.5;
  28.  
  29. int c = 1;
  30.  
  31. cout << " answer 1 is " << mystery(a, 2, c) << endl;
  32.  
  33. cout << " answer 2 is " << mystery(a, 1, c) << endl;
  34.  
  35. a = 5;
  36.  
  37. cout << " answer 3 is " << mystery(a, b, c) << endl;
  38.  
  39. a = 2;
  40.  
  41. b = 2.5;
  42.  
  43. cout << " answer 4 is " << mystery(a, b, b) << endl;
  44.  
  45. cout << " answer 5 is " << mystery(a,mystery(a, b, b),c)<< endl;
  46.  
  47. return 0;
  48.  
  49. }
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
 answer 1 is 3
 answer 2 is 2
 answer 3 is 3
 answer 4 is 4
 answer 5 is 5