X hits on this document

154 views

0 shares

0 downloads

0 comments

20 / 46

© S. Uchitel, 2004

20

Constructors

Determine how instances are built

Construct the attributes if they are complex types.

Initialise the attributes.

Check constraints on parameters e.g., range of values.

Have the same name as the class

Used in conjunction with new

New allocates memory in the heap and calls the constructor method

Every class has a constructor.

A class may have multiple constructors (this is called overloading, more on this later)

Document info
Document views154
Page views154
Page last viewedSat Jan 21 04:29:32 UTC 2017
Pages46
Paragraphs816
Words2901

Comments