A very not nice way to get access to private members is to put '#define private public' before the header file #include of the class you want to access the private members of.
Reference: Pattern Hatching by John Vlissides, Addison-Wesley, 1998., p. 47.
The comma in the following statement is not the comma operator:
for (int i = 0, j = 0; i < 10; ++i) {}It is just part of the declaration statement.
Reference: "C++ Gotchas" by Stephen C. Dewhurst, Addison-Wesley, 2002, p. 40.
The output from the following code is undefined:int i = 1;{int i = i;cout << i << endl;}
Reference: C++ Gotchas by Stephen C. Dewhurst. Addison-Wesley, 2002., p. 53.
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.