12 Sep
2010
12 Sep
'10
11:03 a.m.
I had to know for absolutely sure so I wrote a little test case and used the debugger to check it. typedef struct complexStruct { double r; double i; } complex; complex a,b; complex *pa,*pb; a.r = 1.0; // Initialize the members a.i = 2.0; b.r = 0.0; b.i = 0.0; pa = &a; // Get a pointer to a and b pb = &b; b = a; // Copy a to b pa = &a; // Get a pointer to a and b and verify with debugger. There is no address change. pb = &b; a.r = 0.0; // Just for fun, change a and make sure b doesn't change in debugger a.i = 0.0; // If a and b were the same address now both would change and they don't This verifies that b = a; copies the members instead of setting b's pointer to a's pointer. -- Mike Frazier www.fracton.org