fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template<typename T1, typename T2>
  5. void Swap(T1& a, T2& b) {
  6. T1 tmp(a);
  7. a = b;
  8. b = tmp;
  9. }
  10.  
  11. int main() {
  12. int a = 5;
  13. double b = 10.3;
  14. Swap(a, b);
  15. cout << "a=" << a << ", b=" << b << endl;
  16. return 0;
  17. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
a=10, b=5