上海交通大学交大密西根 ·联合学院一 181 UM-SJTU Joint Institute University of Michigan Shanghal Jiao Tong University Chapter 9 Objects and Classes
Chapter 9 Objects and Classes Chapter 9 Objects and Classes
上海交通大学交大密西根 ·联合学院一 81 UM-SJTU Joint Institute University of Michigan Shanghal Jiao Tong University Objectives To understand objects and classes,and use classes to model objects (§9.2) To understand the role of constructors when creating objects($9.3). To learn how to declare a class and how to create an object of a class (§9.4). To know how to separate a class declaration from a class implementation (9.5). To access object members using pointers($9.6). To create objects using the new operator on the heap (9.7)
Objectives Objectives • To understand objects and classes, and use classes to model objects (§9.2). • To understand the role of constructors when creating objects (§9.3). • To learn how to declare a class and how to create an object of a class (§9.4). • To know how to separate a class declaration from a class implementation (§9.5). • To access object members using pointers (§9.6). • To create objects using the new operator on the heap (§9.7)
上海交通大学交大密西根 ·联合学院一 ■ 81T UM-SJTU Joint Institute University of Michigan Shanghal Jiao Tong University Objectives To declare private data fields with appropriate get and set functions for data field encapsulation to make classes easy to maintain (9.9). To understand the scope of data fields (9.10). To reference hidden data field using the this pointer (9.11). To develop functions with object arguments($9.12). To store and process objects in arrays($9.13). ● To apply class abstraction to develop software (9.14- 9.15). To initialize data fields with a constructor initializer (9.16)
Objectives Objectives • To declare private data fields with appropriate get and set functions for data field encapsulation to make classes easy to maintain (§9.9). • To understand the scope of data fields (§9.10). • To reference hidden data field using the this pointer (§9.11). • To develop functions with object arguments (§9.12). • To store and process objects in arrays (§9.13). • To apply class abstraction to develop software (§§9.14- 9.15). • To initialize data fields with a constructor initializer (§9.16)
上海交通大学交大密西根 联合学院 81 UM-SJTU Joint Institute University of Michigan Shanghal Jiao Tong University O0 Programming Concepts Object-oriented programming (OOP)involves programming using objects.An object represents an entity in the real world that can be distinctly identified.For example,a student,a desk,a circle,a button,and even a loan can all be viewed as objects.An object has a unique identity,state,and behaviors.The state of an object consists of a set of data fields (also known as properties)with their current values.The behavior of an object is defined by a set of functions
OO Programming Concepts OO Programming Concepts • Object-oriented programming (OOP) involves programming using objects. An object represents an entity in the real world that can be distinctly identified. For example, a student, a desk, a circle, a button, and even a loan can all be viewed as objects. An object has a unique identity, state, and behaviors. The state of an object consists of a set of data fields (also known as properties) with their current values. The behavior of an object is defined by a set of functions
上海交通大学交大密西根 联合学院·一 81 UM-SJTU Joint Institute University of Michigan Shanghal Jiao Tong University Introduction To Classes The basic unit of abstraction in C++is the class. -A class is used to encapsulate some piece of user- defined data and the operations that access and manipulate that data. A class is the blueprint from which an object is created-put another way,an object is an instance of a class. In fact,starting from our very first example,we are experiencing defining class ourselves like MessageT, AddIntegersT
Introduction To Classes Introduction To Classes • The basic unit of abstraction in C++ is the class. – A class is used to encapsulate some piece of userdefined data and the operations that access and manipulate that data. – A class is the blueprint from which an object is created — put another way, an object is an instance of a class. – In fact, starting from our very first example, we are experiencing defining class ourselves like MessageT, AddIntegersT, …