compiler | executable | linker | object code |
preprocessor | source code | system header file | system library |
temporary source code | user header file |
namespace GameDebugging{ void PrintWonder(WonderT w); }
This is will cause problems if the programmer has declared identifiers which are the same as the identifiers in the standard namespace. In this case, the code, which compiled before the header file was included, will no longer compile.
There are a number of differences between these two array types. The C style array can only be passed by reference, while the STL array can be passed by reference or by value. The assignment operator in the C style array is a shallow copy, while a deep copy is performed in the STL array. There is no safe indexing function in the C style array while the STL array has the at function which will perform bounds checking and throw an exception if the index is out of bounds. The STL array has a number of additional functions such as front, back, and iterators which the C style array is missing.
It seems to me that you really should mention the deep copy provided by the = operator and the ability to pass by value.
Mentioning that "The STL array provides many functions." without any supporting information is probably insufficient. You really should mention at least at, and =.
int x = 5; int & y = x; y = 7;
The first problem encountered that it is not truly a pass by value for the dynamic portion of the class. Changes to the "value" parameter will be reflected in the argument, which is unexpected behavior.
The second problem is that if the class has a destructor which properly frees memory, the memory for the parameter, and thus for the argument will be destroyed. This results in the argument having a "dangling" pointer, or a pointer that points to memory which has been deallocated.
I probably did not grade this question carefully enough. I should have taken off points if you did not mention the two problems I described above.
int x = 0; try { x++; AFunctionCall(); x++; } catch (int y) { x+=y }Assume that no other catch statements are executed and that somewhere in the call sequence starting at AFunctionCall the statement throw 10; is executed.
x is assigned a value of 0 The try block is entered x is incremented The function is called The throw occurs The catch block is executed with y = 10 x is set to 11