Sunday, February 28, 2010

Static Declaration

Given: static class A {int i;} X;A a; Then: 'a' is not static. Note: X is static.
Reference: "C++ Gotchas" by Stephen C. Dewhurst. Addison-Wesley, 2002., p. 55.

Friday, February 26, 2010

Inlined Free Functions

You can declare a free function to be inline.

Wednesday, February 24, 2010

References to Constants

The following compiles: const int &i = 12;
Reference: "C++ Gotchas" by Stephen C. Dewhurst. Addison-Wesley, 2002., p. 112.

Monday, February 22, 2010

Implicit Pointer Conversions

Implicit conversions of 'pointers to members' are in the opposite direction of implicit conversions of 'pointers to classes'.
Reference: "C++ Gotchas" by Stephen C. Dewhurst. Addison-Wesley, 2002., p. 122.

Saturday, February 20, 2010

Pass by Value

An argument passed by value to a function is passed by initialization and not by assignment.
Reference: "C++ Gotchas" by Stephen Dewhurst. Addison-Wesley, 2002., p. 126.

Thursday, February 18, 2010

Copy Assignment Operator

A derived class cannot inherit the copy assignment operator from its base class.
Reference: "C++ Gotchas" by Stephen C. Dewhurst. Addison-Wesley, 2002., p. 132

Tuesday, February 16, 2010

Copy Constructor

A compiler-generated implicit copy constructor uses assignment instead of initialization for copying pointers, enums, and built-in types; whereas it uses initialization for copying non-scalar user-defined types.
Reference: "C++ Gotchas" by Stephen C. Dewhurst, Addison-Wesley, 2002., p. 133.