tailieunhanh - Lecture Practical C++ programming - Chapter 13: Simple classes

In this chapter we define a simple stack. The first version uses procedures and a structure, the second version uses a class. The class version of the stack is very similar to the procedure/structure version of the stack, except that the procedures (member functions) and structures are integrated. That means that you don’t have to pass the structure as the first parameter to each procedure. | Chapter - 13 Simple Classes Practical C Programming Copyright 2003 O Reilly and Associates Page 1 Stack Definition Data A place to store the items put on and taken from the stack. Implemented as an array . Obvious operations Push -- Add an element to the top of the stack other elements are pushed down . Pop -- Remove the top element from the stack other elements are popped up . Hidden operations Construction -- The creation and initialization of the stack Destruction -- The clean up done when the stack is destroyed. Practical C Programming Copyright 2003 O Reilly and Associates Page 2 ----- T. r ----- r r X Stack Implementation as Struct Practical C Programming Copyright 2003 O Reilly and Associates Page