Do not include a .cpp file inside another .cpp file [Link: 1-5 points]
If you write
#include "tools.cpp"you are linking incorrectly. Use #include "tools.h"and link correctly. |
Use parentheses in preprocessor definitions where appropriate [Preprocessor: 1 point] (optional)
The preprocessor can define macros with parameters. For example,
#define max(x,y) = (((x) > (y)) ? (x) : (y))causes statement m = max(a+1,b);to be replaced by m = (((a+1) > (b)) ? (a+1) : (b));Notice that each parameter in the definition of max is enclosed in parentheses, as it should be, and the entire right-hand side is parenthesized. Ensure that substitutions cannot cause precedence rules to yield a reparse. For example #define successor(x) x+1does not parenthesize. It causes m = 2*successor(n-i);to be replaced by m = 2*n-i+1;which is not what was intended. A correct definition of successor is #define successor(x) ((x)+1) |