May 2002
Beginner
320 pages
6h 18m
English
Returning to the broader picture, Listing 12.2 shows the Accumulate() function in main.cpp with some minor changes that enable it to use the tape.
1: float Accumulate 2: (const char theOperator,const float theOperand) 3: { 4: static float myAccumulator = 0; // Set at program start 5: 6: switch (theOperator) 7: { 8: case '+': 9: myAccumulator = myAccumulator + theOperand; 10: break; 11: 12: case '-': 13: myAccumulator = myAccumulator - theOperand; 14: break; 15: 16: case '*': 17: myAccumulator = myAccumulator * theOperand; 18: break; 19: 20: case '/': 21: myAccumulator = myAccumulator / theOperand; 22: break; 23: *24: case '?': *25: break; 26: 27: default: 28: ... |
Read now
Unlock full access