final exam...make sure you have it mastered!!!
I got this on an interview once!
write a little program method to switch the contents of two pointers
Code:
#include <iostream>
using namespace std;
void switchx(code goes here)
{
code goes here
}
int main()
{
int* p1 = new int();
*p1 = -100;
int* p2 = new int();
*p2 = 100;
cout<<"before "<<*p1<<" ,"<<*p2<<endl;
switchx(&p1, &p2);
cout<<"after "<<*p1<<" ,"<<*p2<<endl;
}
answer on request!