Quite often I rediscover my own old posts and learn new things from it. This time I am revisiting the very first post http://cpptruths.blogspot.com/2005_06_19_cpptruths_archive.html
I came up with a puzzle to "entertain" you guys! Predict the output of following program. You know where to look at for the explanation.
const int FIRST_TIME = 1;
template <typename T>
void func (T &)
static int var;
if (FIRST_TIME == var)
cout << "Printed once." << endl;
cout << "Printed more than once." << endl;
I would rather have a static checker to guard me against such subtle things.