 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| • |
Just
like C++, we use the keyword class to mean that we are creating
|
|
a new
type
|
|
|
– |
class
Mytype {…} creates a new data type
|
|
| • |
And,
creating objects of this type is done using new:
|
|
|
– |
Mytype
object = new Mytype();
|
|
|
| • |
Like
C++, our classes have data members (fields) and member
|
|
|
functions
(methods)
|
|
| • |
Just
like objects outside of a class, data members can be of a
|
|
|
primitive
type or can be references to another user defined class type
|
|
|
(requiring
the use of new to actually create an instance of them)
|
|
| • |
Unlike C++, primitive types can be initialized directly at the
point of
|
|
|
definition
in the class and references can be initialized to connect to
|
|
|
objects
in the class as well
|
|