 |
|

What will the following code output?
class MyInt {
public:
int num;
MyInt();
MyInt(int n);
};
MyInt::MyInt()
{
}
MyInt::MyInt(int n)
{
num=n;
}
void DoSomething(MyInt *ptrA, MyInt *ptrB)
{
int x = ptrA->num;
ptrA->num = ptrB->num;
ptrB->num = x;
}
int main()
{
MyInt *p1;
MyInt *p2;
p1 = new MyInt(3);
p2 = new MyInt(4);
DoSomething(p1,p2);
cout << p1->num << " " << p2->num << endl;
return 0;
}
|
 |
| |
|
|
 |