Hi,
Could anyone explain to me why this works:
#include "stdafx.h"
#include <iostream>
using namespace std;
class A
{
public:
A()
{
a = 0;
}
int a;
};
void change(A* source, A* destination)
{
destination = source;
}
int _tmain(int argc, _TCHAR* argv[])
{
A* ob1 = new A;
ob1->a = 1;
A* ob2 = new A;
//ob2 = ob1; //THIS WORKS AS INTENDED
//cout << ob2->a;
change(ob1, ob2);//THIS DOESN'T
cout << ob2->a;
system("pause");
return 0;
}
I completely do not understand this.
Thank you