Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "test.h"
- using namespace std;
- template<typename T>
- void swap_t( T& arg1 , T& arg2)
- {
- T tmp;
- tmp = arg1;
- arg1 = arg2;
- arg2 = tmp;
- }
- int main()
- {
- int i=3;int j=2;
- swap_t(i,j);
- cout << i << " " << j << endl;
- test obj1, obj2;
- obj1.m_1 = 10;
- obj2.m_1 = 20;
- swap_t(obj1.m_1 ,obj2.m_1);
- cout << obj1.m_1 << " " << obj2.m_1 << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement