Untitled
unknown
plain_text
4 months ago
692 B
35
Indexable
#include <iostream> using namespace std; template<class T> void mySwap(T &a, T &b) { T temp = a; a = b; b = temp; } int main() { int x1 = 4, y1 = 7; float x2 = 4.5f, y2 = 7.5f; double d1 = 10.5, d2 = 20.5; cout << "Before swap:"; cout << "\nx1 = " << x1 << "\ty1 = " << y1; cout << "\nx2 = " << x2 << "\ty2 = " << y2; cout << "\nd1 = " << d1 << "\td2 = " << d2; mySwap(x1, y1); mySwap(x2, y2); mySwap(d1, d2); cout << "\n\nAfter swap:"; cout << "\nx1 = " << x1 << "\ty1 = " << y1; cout << "\nx2 = " << x2 << "\ty2 = " << y2; cout << "\nd1 = " << d1 << "\td2 = " << d2; return 0; }
Editor is loading...
Leave a Comment