4.1. How to Implement a Class
OK, where do we start? In general, we start with an abstraction. Consider a stack. A stack is a fundamental abstraction of computer science. It allows for the nesting and retrieval of values in a last-in, first-out sequence. We nest values by pushing a new value onto the stack, and we retrieve them by popping the last value pushed on the stack. Other operations that users often require are to ask whether a stack is full or empty and to determine the size of the stack. A stack may also support peeking at the last value pushed on the stack.
In the description of a stack I italicized the words that represent operations that users will likely want to apply to objects of our stack class.
What type of elements should ...
Get Essential C++ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.