On occasion, a program needs to build, maintain and use a collection of related data, where it is natural to consider the collection to be, in some sense, a whole. If we intend to make much use of stacks, then it might be a worthwhile investment to write some functions dedicated to building and using stacks. The combination of some data and some dedicated functions is called an object.
Every object belongs to some specific class of similar objects.
We will say that a stack is an object of the Stack class. For example, for objects of the Stack class we will need a method for adding a new item, and a method for retrieving the last-added item. An object needs one or more variables to represent its data. Such variables are called fields. Thus for a stack we may choose to have a single field, a list of items.