Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * pointer.cpp
- *
- * Created on: 15 Eki 2011
- * Author: Serdar Kuzucu
- * WebPage: http://blog.asosyalbebe.com
- */
- #include <iostream>
- using namespace std;
- void swapp(int *x, int *y) {
- int temp = *x;
- *x = *y;
- *y = temp;
- }
- void swappp(int &x, int &y) {
- int temp = x;
- x = y;
- y = temp;
- }
- int main() {
- int x = 5, y = 2;
- cout << "x = " << x << " | y = " << y << endl;
- swapp(&x, &y);
- cout << "x = " << x << " | y = " << y << endl;
- swappp(x, y);
- cout << "x = " << x << " | y = " << y << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment