O'Reilly logo

SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Tape

The Tape() function is fairly simple, and is coded in main.cpp.

Listing 12.1. Tape() in main.cpp
 1: void Tape(const char theOperator,const float theOperand) 2: { 3: static const int myTapeSize = 20; // Array size 4: 5: static char myOperator[myTapeSize]; // Operator part 6: static float myOperand[myTapeSize]; // Operand part 7: 8: static int myNumberOfEntries = 0; // What's in tape now 9: 10: // Remember that arrays start with element 0 11: // And that the highest element is the size - 1; 12: 13: if (theOperator != '?') // Add to the tape 14: { 15: if (myNumberOfEntries < myTapeSize) // We have room 16: { 17: myOperator[myNumberOfEntries] = theOperator; 18: myOperand[myNumberOfEntries] = theOperand; 19: myNumberOfEntries++; 20: } 21: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required