X hits on this document

105 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 views105
Page views105
Page last viewedMon Dec 05 18:47:12 UTC 2016
Pages46
Paragraphs816
Words2901

Comments