tailieunhanh - Absolute C++ (4th Edition) part 72

Absolute C++ (4th Edition) part 72. KEY BENEFIT: C++ programming concepts and techniques are presented in a straightforward style using understandable language and code. KEY TOPICS: C++ Basics; Flow of Control; Function Basics; Parameters and Overloading; Arrays; Structures and Classes; Constructors; Operator Overloading, Friends, and References; Strings; Pointers and Dynamic Arrays; Separate Compilation and Namespaces; Streams and File I/O; Recursion; Inheritance; Polymorphism and Virtual Functions; Templates; Linked Data Structures; Exception Handling; Standard Template Library; Patterns and UML. MARKET: Useful for both beginning and intermediate C++ programmers. . | Linked List Applications 717 Display Interface File for a Stack Template Class part 2 of 2 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 public Stack Initializes the object to an empty stack. _Copy constructor Stack const Stack T aStack Stack T operator const Stack T rightSide virtual Stack --------------The destructor destroys the stack and returns all the memory to the freestore. void push T stackFrame Postcondition stackFrame has been added to the stack. T pop Precondition The stack is not empty. Returns the top stack frame and removes that top stack frame from the stack. bool isEmpty const Returns true if the stack is empty. Returns false otherwise. private Node T top StackSavitch endif STACK_H operations you can perform on a stack adding an item to the stack and removing an item from the stack. Adding an item is called pushing the item onto the stack and so we called the member function that does this push. Removing an item from a stack is called popping the item off the stack and so we called the member function that does this pop. The names push and pop derive from a particular way of visualizing a stack. A stack is analogous to a mechanism that is sometimes used to hold plates in a cafeteria. The mechanism stores plates in a hole in the countertop. There is a spring underneath the plates with its tension adjusted so that only the top plate protrudes above the countertop. If this sort of mechanism were used as a stack data structure the data would be written on plates which might violate some health laws but still makes a good analogy . To add a plate to the stack you put it on top of the other plates and the weight of this new plate pushes down the spring. When you remove a plate the plate below it pops into view. Display shows a simple program that illustrates how the Stack class is used. This program reads a line of text one character at a time and places the characters in a stack. The .

TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG