Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<array>
- #include<algorithm>
- //template <class T, class U>
- //std::pair<U, T> My_Swap(T a, U b) {
- // return std::make_pair(b, a);
- //}
- //
- //template <class T>
- //class MyClass {
- // T arr[3];
- //public:
- // MyClass(T a, T b, T c) :arr[0](a), arr[1](b), arr[2](c){}
- // T* get_arr() { return arr; }
- //};
- void main() {
- int a = 5;
- double b = 5.5;
- std::cout << "\n Before swap: " << a << " " << b;
- auto temp = My_Swap(a, b);
- a = temp.second;
- b = temp.first;
- std::cout << "\n After swap: " << a << " " << b;
- MyClass<int> c(0, 1, 2), d(5, 7, 9);
- auto temp_2 = My_Swap(c, d);
- std::cout << "\n Before swap: ";
- for (int i = 0; i < 3; i++)
- std::cout << c.get_arr()[i] << " " << d.get_arr()[i] << std::endl;
- c = temp_2.second;
- d = temp_2.first;
- std::cout << "\n After swap: ";
- for (int i = 0; i < 3; i++)
- std::cout << c.get_arr()[i] << " " << d.get_arr()[i] << std::endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement