My problem is after change the value of Masked raider the jimmy changed,but when set jimmy = "not ok";
Masked raider did not change,how to explain it?
When you changed jimmy to "not ok", you pointed it to a different object (the string literal "not ok"). At that point, jimmy no longer aliases masked_raider.
deceptikon
Challenge Accepted
3,425 posts since Jan 2012
Reputation Points: 822
Solved Threads: 473
Skill Endorsements: 56
Question Answered as of 3 Months Ago by
deceptikon
and
andrag73 If you do:
masked_raider = jimmy;
You will see the change you ask !
Um, no. That won't compile because masked_raider is an array; it doesn't support direct assignment. The only way to restore the alias is to assign the address of the first element of masked_raider to jimmy (which may be what you really meant, but accidentally reversed the assignment):
/* Option 1: Implicit conversion to a pointer */
jimmy = masked_raider;
/* Option 2: Explicit conversion to a pointer */
jimmy = &masked_raider[0];
/* Option 3: Weird stuff (not recommended) */
jimmy = &*masked_raider;
deceptikon
Challenge Accepted
3,425 posts since Jan 2012
Reputation Points: 822
Solved Threads: 473
Skill Endorsements: 56