CIS-260 Home http://www.c-jump.com/bcc/
Name
Comments
Attributes
Constructors
Accessors
public and private operations.
|
|
|
|
Multiline comment /**/
Single are comment //
Attributes represent the state of an object.
Attributes store object data.
Attributes can be static, public, and private.
Anything public becomes part of the interface.
Anything private is part of object implementation.
Conservative design means keeping private as much as possible.
Static attributes are shared by all objects instantiated for a given class.
This means that only a single copy of static attribute is allocated in memory.
public class ClassicSingleton { private static ClassicSingleton instance = null; protected ClassicSingleton() { // Exists only to defeat instantiation. } public static ClassicSingleton getInstance() { if( instance == null ) { instance = new ClassicSingleton(); } return instance; } }
Class definitions can have multiple constructors.
Constructors are operations that aide object creation.
Constructors are primarily responsible for initialization of object attributes.
Default constructor has no parameters.
Other constructors have parameter lists (see next slide).
Default constructors are provided for free unless explicitly defined.
|
|
|
|
Similar to private data attributes, operations can also be private.
Private operations are part of object implementation.
Implementation is hidden from other classes.
Private operations can be used only inside the scope of the class.