When you are passing your object into the function, you are actually passing a copy of the object. You need to pass by reference like so:
1 2
void change2 (complex &A)
{A.r=2;}
This will pass a reference to the object so that you can modify the original instead of modifying a copy that is destroyed at the end of the function's scope.