Introduction To Classes and Objects: 2006 Pearson Education, Inc. All Rights Reserved
Introduction To Classes and Objects: 2006 Pearson Education, Inc. All Rights Reserved
3
Introduction to
Classes and
Objects
2006 Pearson Education, Inc. All rights reserved.
2
3.1 Introduction
3.2 Classes, Objects, Member Functions and Data Members
3.3 Overview of the Chapter Examples
3.4 Defining a Class with a Member Function
3.5 Defining a Member Function with a Parameter
3.6 Data Members, set Functions and get Functions
3.7 Initializing Objects with Constructors
3.8 Placing a Class in a Separate File for Reusability
3.9 Separating Interface from Implementation
3.10 Validating Data with set Functions
3.1 Introduction
• Programs from Chapter 2
– All statements were located in function main
• Typically
– Programs will consist of
• Function main and
• One or more classes
– Each containing data members and member functions
• Constructors
– Functions used to initialize an object’s data when it is
created
• Call made implicitly when object is created
• Must be defined with the same name as the class
• Cannot return values
– Not even void
– Default constructor has no parameters
• The compiler will provide one when a class does not explicitly
include a constructor