#include <iostream>
usingnamespace std;
#include "secret.h"
void swap(long a, long b)
{
long temp;
temp=a;
a=b;
b=temp;
}
int main()
{
long a=1;
long b=2;
cout << a << ' ';
cout << b << endl;
swap(a,b);
cout << a << ' ';
cout << b << endl;
cin.get();
return 0;
}
The output of this code is:
1 2
2 1
And it actually does the swapping, it's not just some output trick, i.e. it works for every pair of constants I initialize a and b to. So... What's inside my secret header that allows me to do that???
Please, if you find an answer don't post it, PM me instead. Thank you!
You are very close! :D Just make it a struct to get rid of the access problems. Oh, and I did it very carefully so as not to have any memory leaks. But if it does the job, I'll accept it, even if it has memory leaks. Oh, and please don't post code! PM me instead.