|
|
 |
|
|
|
|
122: cout << is ;
123: cout << sparky.GetAge() << years old.;
124: return 0;
125: } |
|
|
|
|
|
|
|
|
AGE: 5
(String Invariants Checked)
(String Invariants Checked)
(String Invariants Checked)
(String Invariants Checked)
(String Invariants Checked)
(String Invariants Checked)
(String Invariants Checked)
(String Invariants Checked)
(String Invariants Checked)
(String Invariants Checked)
Sparky is (Animal Invariants Checked)
5 Years old. (Animal Invariants Checked)
(Animal Invariants Checked)
(Animal Invariants Checked)
Sparky is (Animal Invariants Checked)
8 years old. (String Invariants Checked)
(String Invariants Checked)
// run again with DEBUG = MEDIUM
AGE: 5
Sparky is 5 years old.
Sparky is 8 years old. |
|
|
|
|
|
|
|
|
Analysis: On lines 8 to 18, the assert() macro is defined to be stripped if DEBUGLEVEL is less than LOW (that is DEBUGLEVEL is NONE). If any debugging is enabled, the assert() macro will work. On lines 20 to 25, EVAL is declared to be stripped if DEBUG is less than MEDIUM; if DEBUGLEVEL is NONE or LOW then EVAL is stripped. |
|
|
|
|
|
|
|
|
Finally, on lines 2732, the PRINT macro is declared to be stripped if DEBUGLEVEL is less than HIGH. PRINT is used only when DEBUGLEVEL is high, and you can eliminate this macro by setting DEBUGLEVEL to MEDIUM, and still maintain your use of EVAL and of assert(). |
|
|
|
|
|
|
|
|
PRINT is used within the Invariants() methods to print an informative message. EVAL is used on line 115 to evaluate the current value of the constant integer AGE. |
|
|
|
|
|