previous
|
start
|
next
Designing the Public Interface of a Class: Constructor Definition
A constructor initializes the instance variables
Constructor name = class name
public BankAccount()
{
// body--filled in later
}
Constructor body is executed when new object is created
Statements in constructor body will set the internal data of the object that is being constructed
All constructors of a class have the same name
Compiler can tell constructors apart because they take different parameters
previous
|
start
|
next