Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void swapping(int *a, int *b);
- int main()
- {
- int *a = new int(5);
- int *b = new int(8);
- cout << "Original: " << *a << ", " << *b << ".\n";
- swapping(a, b);
- cout << "Swapped: " << *a << ", " << *b << ".\n";
- return 0;
- }
- void swapping(int *a, int *b){
- if(a && b){
- //cout << *a << endl;
- int *c = new int(*a);
- //cout << *c << endl;
- delete a;
- a = new int(*b);
- //cout << *a << endl;
- delete b;
- b = new int(*c);
- //cout << *b << endl;
- delete c;
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement