// CS301P Lab 6 Problem KST Learning #include #include using namespace std; template void swap_value(T a , T b) { T temp = a; a = b; b = temp; } template void swap_reference(T &a , T &b) { T temp = a; a = b; b = temp; } template void swap_pointer(T *a , T *b) { T temp = *a; *a = *b; *b = temp; } main() { int a = 5 , b = 10; cout << "==================== Function Call By Value ===================="; cout << "\n\nBefore Swapping"; cout << "\na = " << a; cout << "\nb = " << b; swap_value(a,b); cout << "\n\nAfter Swapping"; cout << "\na = " << a; cout << "\nb = " << b; cout << "\n\n==================== Function Call By Reference ===================="; cout << "\n\nBefore Swapping"; cout << "\na = " << a; cout << "\nb = " << b; swap_reference(a,b); cout << "\n\nAfter Swapping"; cout << "\na = " << a; cout << "\nb = " << b; cout << "\n\n==================== Function Call By Pointer ===================="; cout << "\n\nBefore Swapping"; cout << "\na = " << a; cout << "\nb = " << b; swap_pointer(&a,&b); cout << "\n\nAfter Swapping"; cout << "\na = " << a; cout << "\nb = " << b; getch(); return 0; }