November 1999
Intermediate to advanced
240 pages
5h 22m
English
Difficulty: 6
How well do you really know the order in which C++ code is executed? Test your knowledge against this problem.
“The devil is in the details.” Point out as many problems as possible in the following (somewhat contrived) code, focusing on those related to control flow.
#include <cassert> #include <iostream> #include <typeinfo> #include <string> using namespace std; // The following lines come from other header files. // char* itoa( int value, char* workArea, int radix ); extern int fileIdCounter; // Helpers to automate class invariant checking. // template<class T> inline void AAssert( T& p ) { static int localFileId = ++fileIdCounter; if( !p.Invariant() ) { cerr << "Invariant failed: file " << localFileId << ...Read now
Unlock full access