/* Lecture code 4.0 * * The perils of an improperly-formed #define constant. Make * sure that you understand why this code doesn't work correctly * and why you should use the const keyword to make constants * instead of using #define! */ #include using namespace std; #define HOURLY_WAGE 14.50 // Wage per hour #define MOWING_LAWNS 14 // Total hours spent mowing lawns #define BEING_A_NINJA 14 // Total hours spent being a ninja. /* Watch out! This line causes problems! */ #define TOTAL_HOURS MOWING_LAWNS + BEING_A_NINJA int main() { /* This doesn't compute the right answer! Make sure that * you understand why! */ double totalEarnings = TOTAL_HOURS * HOURLY_WAGE; cout << '$' << totalEarnings << endl; return 0; }