Orion Lawlor's Short but Horrifying C++ Examples

These short examples illustrate the (oft bizarre) syntax and semantics of the more esoteric features of C++.
beer.cpp A carefully obfuscated partial-specialization template metaprogram to spit out the lyrics to "9 bottles of beer".
beer_simple.cpp The non-obfuscated partial-specialization template metaprogram to spit out the lyrics to "9 bottles of beer".
command_line.cpp < < <
const_members.cpp Shows the semantics of "const" member functions. A "const" member function does not change the object, and hence can be called on a const object.
constructor.cpp Shows how to use various constructor types.
constructor_destructor.cpp Shows the (strange) order in which constructors/destructors get called.
constructor_sub.cpp Shows how to call a member object's constructor, and how to define a constructor outside the class declaration.
const_types.cpp Shows the semantics of all the flavors of "const" types.
dynamic_cast.cpp Shows how to use dynamic_cast.
function_ptr.cpp Shows how to use pointer-to-functions.
log_2_bad.cpp Shows the dangers of using floating-point "log" math routine to calculate base-2 integer logs.
member_ptr.cpp Shows how to use pointer-to-member functions.
operator_new.cpp Shows how to define a custom operator new to allocate all classes.
operator_new_void.cpp Shows how to use the buildin "placement new" operator to call a C++ class's constructor on an existing chunk of memory (allocated some other way, like malloc).
overload_addition.cpp Shows how to overload a class foo's addition operator (+).
overload_all.cpp Shows how to overload a bunch of cast operators for a class.
overload_brackets.cpp Shows how to overload a class foo's bracket (array index) operator.
overload_cast.cpp Shows how to overload a class cast operator.
overload_output.cpp Shows how to overload a class foo's ostream output operator (<<).
overload_parenthesis.cpp Shows how to overload a class foo's function call operator (parenthesis).
return_to_const_ref.cpp Shows when the destructor gets called on a compiler-generated return value.
rtti.cpp Shows how to use run-time type information.
table_bit_count.cpp Build a table that counts the number of set bits in the input byte.