Some classes, such as our hello application, have just one or more method that will be executed as a program. Only one instance of these classes is created (by the interpreter).
|
Other classes are used to structure data, such as the previous example. Another example might be to have a class to represent type Complex. It would have
-
variables to hold the real and imaginary parts of each instance
-
a method called Complex to initialize those variables on creation
-
methods called add, subtract, and so on to operate on each instance of the complex class.
|
A computational class could create several instances of the class Complex and use them with the methods for arithmetic.
|
Note an object carries a lot of "baggage" compared to a simple type. We are trying to get efficient lightweight classes into language
|