Advertisement
andruhovski

prog0304-demo2

Feb 23rd, 2016
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. using namespace std;
  4. template <typename T>
  5. T find_min_max(T* mas, size_t n);
  6.  
  7. template <class T>
  8. void my_swap(T& x, T& y)
  9. {
  10.     T z;    z = x;      x = y;      y = z;
  11. };
  12.  
  13. template <class T>
  14. void my_swap(char *x, char *y)
  15. {
  16.     cout << "Demo of swap" << endl;
  17. };
  18.  
  19. int _tmain(int argc, _TCHAR* argv[])
  20. {
  21.  
  22.     int a1 = 45, a2 = 56;
  23.     char *s1 = "AAA", *s2 = "BBB";
  24.     cout << a1 << " " << a2 << endl;
  25.     my_swap<int>(a1, a2);
  26.     cout << a1 << " " << a2 << endl;
  27.  
  28.     cout << s1 << " " << s2 << endl;
  29.     my_swap<char *>(s1, s2);
  30.     cout << s1 << " " << s2 << endl;
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement