Errata: For the code to compile correctly, the line "using namespace std;" must be removed. Sorry about that.