Chapter 3: Objects

Lecture Goals


Constructing Objects

	string greeting = "Hello";
cout << greeting.substr(0,4);

Syntax 3.1: Constant Object Construction

Class_name(construction parameters);
Example:
Time(19, 0, 0);
Purpose: Construct a new object for use in an expression.

Syntax 3.2: Object Variable Definition

Class_name variable_name(construction parameters);
Example:
Time homework_due(19, 0, 0);
Purpose: Define a new object variable and supply parameter values for initialization.


Using Objects

Using Objects (time1.cpp)

Using Objects (time2.cpp)


Real-Life Objects

Real-Life Objects (employee.cpp)