Each object implements its state using a set of
instance variableS. An
instance variable can be a nested object, a pointer to an object, a primitive data item such as an int or a double, or an array of any of the preceding types.
The POV classification process results in a problem-specific class hierarchy that can then be elaborated using standard Smalltalk development tools (that is, to add
instance variables, method names, method code).
When a node::visit operation executes, it first adds the parameter p into the running sum stored in the receiver's sum
instance variable. It then checks the receiver's marked
instance variable to see if the traversal has already visited the receiver.
The
instance variable city has automatically generated accessor (also the public method) city.
In a pure object-oriented language like Smalltalk, the end user has no way to access
instance variables directly; this must be done by writing methods or functions which access them.
So if the programming language supports class and
instance variables, the representation should contain structural components corresponding to both class and
instance variables.
A class specifies the common structure (attributes,
instance variables) and behavior (operations, methods) of a set of objects, allowing just one implementation of the behavior of these objects.