Tuesday, March 2, 2010

Scope

The following code prints out a 1:
const int i = 1;
{
enum
{
i = i
};
cout << i << endl; } Note that it looks like it could have undefined behavior, but it doesn't. Reference: "C++ Gotchas" by Stephen Dewhurst Addison-Wesley, 2002., p. 54.

No comments:

Post a Comment