Asume that f() returns a reference to an integer (int & f();), f()+=5; and f()=f()+5; are different, explain how and give pesudo code for f() to illustrate this difference.
If p is an int *p, what is the difference between, these two statement in C++:
if (p!=NULL && *p !=0)....
if (*p !=0 && p !=NULL)....
f()+=5could be different fromf()=f()+5 iff()returned a reference to a different integer at each call. This could only happen iff()read from some global variable which was different each time that it was called.The difference between
if (p!=NULL && *p !=0)andif (*p !=0 && *p !=NULL)is that the first one checks whetherpis null and then checks whether theintthatppoints to is0. The second one only checks whether theintthatppoints to is0(and performs this check twice).