Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- template <typename T>
- T find_min_max(T* mas, size_t n);
- template <class T>
- void my_swap(T& x, T& y)
- {
- T z; z = x; x = y; y = z;
- };
- template <class T>
- void my_swap(char *x, char *y)
- {
- cout << "Demo of swap" << endl;
- };
- int _tmain(int argc, _TCHAR* argv[])
- {
- int a1 = 45, a2 = 56;
- char *s1 = "AAA", *s2 = "BBB";
- cout << a1 << " " << a2 << endl;
- my_swap<int>(a1, a2);
- cout << a1 << " " << a2 << endl;
- cout << s1 << " " << s2 << endl;
- my_swap<char *>(s1, s2);
- cout << s1 << " " << s2 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement