Skip to content
Archive of posts filed under the Brain Teasers category.

Brain Teaser: Streaming An Enumeration In C++

Streaming an enumeratoin in C++, what could be easier? Can you spot the bug in the following code?

typedef enum {
SEASON_UNDEF,
SEASON_SUMMER,
SEASON_AUTUMN,
SEASON_WINTER,
SEASON_SPRING,
SEASON_NUM_TYPES,
} SEASON;
 
 
std::ostream& operator<<(std::ostream& rOs,
[...]