fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template <typename T>
  5.  
  6. T foo(T &a, T &b)
  7. {
  8. T c;
  9. c = a;
  10. a = b;
  11. b = c;
  12. }
  13.  
  14. int main() {
  15.  
  16. T a, b;
  17.  
  18. cout << "Vvedite znachenie a:" << endl;
  19. cin >> a;
  20. cout << "Vvedite znachenie b" << endl;
  21. cin >> b;
  22.  
  23. foo(a, b);
  24.  
  25. cout << "a= " << a << endl;
  26. cout << "b= " << b << endl;
  27.  
  28. return 0;
  29. }
Compilation error #stdin compilation error #stdout 0s 16064KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:16:2: error: ‘T’ was not declared in this scope
  T a, b;
  ^
prog.cpp:19:9: error: ‘a’ was not declared in this scope
  cin >> a;
         ^
prog.cpp:21:9: error: ‘b’ was not declared in this scope
  cin >> b;
         ^
stdout
Standard output is empty