Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- template<class T>
- void swap(T& x,T& y)
- {
- T temp = x;
- x = y;
- y = temp;
- }
- int main(){
- float a = 1.12, b = 2.45;
- swap(a,b);
- std::cout << "a: " << a << std::endl << "b: " << b << std::endl;
- char c = '-', d = '$';
- swap(c,d);
- std::cout << "c: " << c << std::endl << "d: " << d << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement