Skip to content

Caught, time and again

Is the solution to this apparent to you?

Given this piece of C++ code:

  // definitions (a and b are primitive types)
  a = b+1;
  if (a == b+1) cout<<"True";
  else cout<<"False";

Under what conditions would the code print "False"?

The answer, when I finally get it, is obvious, but I manage to forget it every time and repeatedly fall into this trap.

2 Comments