fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template <class T>
  5. void swap(T *a, T *b) {
  6. T t = *a;
  7. *a = *b;
  8. *b = t;
  9. }
  10.  
  11. template <typename T1, typename T2>
  12. void print2(T1 t1, T2 t2) {
  13. cout << t1 << ' ' << t2 << endl;
  14. }
  15.  
  16. int main() {
  17.  
  18. int a = 100;
  19. int b = 999;
  20. print2(a, b);
  21. swap(&a, &b);
  22. print2(a, b);
  23.  
  24. char c = 'C';
  25. char d = 'D';
  26. print2(c, d);
  27. swap(&c, &d);
  28. print2(c, d);
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
100 999
999 100
C D
D C