Quote (KrzaQ2 @ Dec 3 2013 05:46pm)
If this is the exact example from your programming class, you should tell your professor that he's a dumbass for not managing his resources correctly. (not only he uses naked new, but also he fails to free allocated memory).
As to the question, check this out:
http://www.youtube.com/watch?v=UvoHwFvAvQE
Basically, you copy the value of a to memory pointed to by x.
After that you change the value of a, but the value stored in x doesn't change.
Had you pointed x to a (x = &a), then 1 would be printed.
oh wow yea that is so obvious now that I think about it. Thanks a lot buddy I appreciate it!