书籍详情
C++面向对象程序设计:基于设计项目的方法
作者:(美)朱海滨, (美)周孟初编著
出版社:清华大学出版社
出版时间:2006-01-01
ISBN:9787302116035
定价:¥45.00
购买这本书可以去
内容简介
本书系统地讨论了利用C++语言进行面向对象程序设计的基本概念、原理、方法和语言机制。本书“原理第一、语言第二”的独特编写方法可以尽量避免读者在用C++学习面向对象程序设计时经常出现的问题,即,利用C++语言编写出非面向对象的程序。本书力图用日常生活实例引入面向对象的基本概念和原理,从而使具有一定生活常识和经验的读者更易于接受。本书基于项目、逐步学习的方法能使读者更愿意编写可运行的C++程序——从实践中学习。这样,本书虽主要面向计算机相关专业的读者编写,但相关工科专业(如电子工程和工业工程)的读者仍然能够根据少量计算机专业基础理解本书内容,并通过本书学习用C++编写面向对象的程序。本书可作为计算机相关专业面向对象程序设计课程的教材,亦可作为其他工科专业学习面向对象程序设计的教材,同时还可以作为程序员或软件工程师的程序设计参考书。本书系统地讨论了利用C++语言进行面向对象程序设计的基本概念、原理、方法和语言机制。本书“原理第一、语言第二”的独特编写方法可以尽量避免读者在用C++学习面向对象程序设计时经常出现的问题,即,利用C++语言编写出非面向对象的程序。本书力图用日常生活实例引入面向对象的基本概念和原理,从而使具有一定生活常识和经验的读者更易于接受。本书基于项目、逐步学习的方法能使读者更愿意编写可运行的C++程序——从实践中学习。这样,本书虽主要面向计算机相关专业的读者编写,但相关工科专业(如电子工程和工业工程)的读者仍然能够根据少量计算机专业基础理解本书内容,并通过本书学习用C++编写面向对象的程序。本书可作为计算机相关专业面向对象程序设计课程的教材,亦可作为其他工科专业学习面向对象程序设计的教材,同时还可以作为程序员或软件工程师的程序设计参考书。
作者简介
朱海滨,现为加拿大尼波星大学(Nipissing University)计算机与数学系助理教授, 尼波星大学学科规划委员会(Academic Planning Committee of Nipissing University)委员,湖南大学软件学院兼职教授,国际电气电子工程师学会(IEEE) 高级会员(senior member), 国际计算机器学会(ACM)会员(member),中国旅美科技学会(CAST |USA)终身会员(life member)。 1988年和1997年分别获中国国防科技大学硕士和博士学位。曾任2003年国际电气工程师协会系统人控制论(IEEE SMC)国际会议程序委员,2004年加拿大软件工程教育年会程序委员,2004年国际电气工程师协会系统 |人 |控制论(IEEE SMC)国际会议程序委员。 曾任美国新泽西理工学院访问教授和特聘讲师,中国国防科技大学教授,国防科技大学学术(科技)委员会委员, 国防科技大学计算机系学术委员会委员, 湖南省计算机学会计算机体系结构与网络专业委员会副主任。 曾获国际并行工程会议(ISPE/CE 2004)最佳论文奖, 国际商用机器公司(IBM)Eclipse创新奖(2004),国际面向对象程序设计系统、语言及应用学术年会(OOPSLA 03)教育家奖(2004),中国国家级优秀教材二等奖一项(2002),中国国家级优秀教学成果二等奖一项(1999),中国部委级科技进步一等奖三项(1991, 1994, 1997),中国部级优秀教材二等奖一项 (1996) 。 主编教材三部,主译教材一部, 助编教材一部, 发表论文50余篇。在中、美、加三国系统讲授过20门计算机专业课程,听课学生数达900(中国300, 美国460,加拿大200)余人。 目前主要研究方向包括面向对象系统及模型,基于角色的协同工作(Role |Based ollaboration),数据挖掘,分布式系统与软件工程,以及远程教育工具与平台。 周孟初,1983年获华东工程学院(现南京理工大学)学士学位;1986年获北京理工大学自动控制系硕士,并于同年加入兵器工业部计算机应用研究所;1987年赴美学习深造,1990年获美国伦塞利尔(Rensselaer)理工学院博士学位。1987—1990年期间,曾先后在伦塞利尔理工学院CIM制造中心,纽约州生产率与技术转让中心任助理研究员。自1990年起,在美国新泽西理工学院任助理教授、副教授及正教授等,1995年获终身教职。创办并主持了离散事件系统实验室。从事Petri网的基本理论与工程应用,计算机集成系统的建模、分析和控制机理,多重生命周期,生物信号,及传感网络等方面的研究。已经发表专著两部,主编及助编研究专著各一部,发表杂志论文60多篇,会议论文100多篇,13篇book chapters。其中在IEEE Transactions发表的长文(regular papers)有24篇。许多论文中的概念、模型、结构、方法和算法等多属首次提出,并得到学术界的承认,有的得到企业界的应用。1998年创办了IEEE Systems, Man and Cybernetics学会的离散事件系统专业委员会并担任其主席。2001年创办了IEEE Robotics and Automation学会的半导体工厂自动化专业委员会并担任其共同主席,委员会吸收了大批工业界人士,先后举办多次研讨会,并在国际一流杂志上多次组织出版了相关专业的专辑,极大地促进了相关领域的发展与工业应用。多次担任重大国际会议的总主席及程序委员会主席。担任多个国际杂志编委。主要奖项有: 1994年美国国家科学基金委研究创新奖; 1994年美国制造工程师协会颁发的“计算机集成制造系统大学领先奖”; 1996年新泽西理工学院院长颁发的该年度Harlen J. Perlis 研究奖(成为该奖自成立以来最年轻的得主,记录保持至今); 2000年 Whos Who in Science and Engineering (Marquis Whos Who), 5th Edition; 2000年德国洪堡基金会的美国资深科学家洪堡研究奖; 2001年新泽西亚美文化委员会的亚裔成就奖以及中国旅美科技协会的学术成就奖; 2002年Who s Who in Engineering Education (WWEE), 2002 edition; 2003年获得IEEE Fellow(院士)称号; 2003年IEEE Systems, Man and Cybernetics Society 杰出贡献奖; 2003年中国自然科学基金海外青年学者合作研究基金奖。 现担任中科院及北京科委海外评审专家, 包括美国NSF在内的多个国家科学基金的项目评审专家。他曾应邀在中国、澳大利亚、法国、德国、意大利、日本、韩国、墨西哥及中国台湾与香港等多处做学术报告。
目录
Part 1Principles of Object\|Oriented Programming
CHAPTER 1Introduction to Object\|Oriented Programming
1.1Object\|Oriented Thinking Methodology6
1.1.1Induction and Deduction6
1.1.2Composition and Decomposition7
1.1.3Object\|Orientation as a Thinking Methodology9
1.2Programming Techniques and Concepts11
1.2.1What is Programming?11
1.2.2Abstraction, Information Hiding and Modeling13
1.2.3Procedural Programming and Modules15
1.2.4Encapsulation18
1.2.5Abstract Data Type20
1.3Object\|Oriented Programming21
1.4Other Programming Paradigms24
1.4.1Imperative Programming25
1.4.2Functional Programming25
1.4.3Logic Programming26
1.4.4Relationships between Object\|Oriented Programming and Other
Paradigms27
1.5Object\|Oriented Languages28
1.5.1Simula 6728
1.5.2Smalltalk29
1.5.3C++30
1.5.4Java31
1.5.5C#32
1.5.6Others33
1.6Summary34
CHAPTER 2Object, Classes and Inheritance
2.1Object39
2.1.1Real\|World Object Properties39
2.1.2Virtual Objects41
2.1.3The External and Internal View of an Object42
2.1.4Definition of an Object43
Contents Object\|Oriented Programming in C++: A Project\|Based Approach 2.2Message43
2.2.1The Only Way to Interact43
2.2.2Definition of a Message44
2.2.3Message Categories45
2.2.4Objects in Programming45
2.3Encapsulation and Protocol45
2.4Class46
2.4.1Abstraction46
2.4.2Classification47
2.4.3The Basic View of a Class48
2.4.4Class Definition49
2.4.5Relationships among Classes50
2.4.6The Characteristics of a Class50
2.5Instantiation51
2.6Metaclass53
2.7Inheritance55
2.7.1The Properties of Inheritance55
2.7.2Inheritance Definition56
2.7.3Categories of Inheritance57
2.7.4Naming Conflicts58
2.7.5Precedence Conflicts59
2.8Superclass and Subclass60
2.8.1Subclassing60
2.8.2Modifiability61
2.9Abstract Class61
2.10Summary63
CHAPTER 3Polymorphism, Dynamic Binding, Overloading and
Other Concepts3.1Polymorphism69
3.1.1General Meanings of Polymorphism69
3.1.2Introduction of Polymorphism to Programming Languages70
3.1.3Categories of Polymorphism71
3.1.4The Drawbacks of Polymorphism73
3.2Overloading75
3.2.1Overloading Based on Scopes 75
3.2.2Overloading Based on Type Signatures76
3.3Static and Dynamic Binding77
3.4Overriding79
3.4.1Overriding Variables80
3.4.2Overriding Methods82
3.5Other Object\|Oriented Programming Concepts82
3.5.1Object Interactions83
3.5.2Design Patterns86
3.5.3Objects and Agents95
3.5.4Object\|Orientation and Reusable Components98
3.6Summary100
CHAPTER 4Object\|Oriented Design
4.1Object\|Oriented Software Engineering105
4.2Object\|Oriented Design108
4.2.1OOA vs. OOD108
4.2.2OOD Steps and Tasks110
4.2.3Discussions114
4.3Unified Modeling Language115
4.3.1Use Case Modeling and Use Case Diagrams115
4.3.2Class and Object Diagrams117
4.3.3Association Diagram118
4.3.4Dynamic Modeling121
4.3.5Other Diagrams122
4.4CASE Tools for Object\|Oriented Design123
4.4.1The Basic Architecture of OO ICASE Tools124
4.4.2Some ICASE Tools for OOA/OOD126
4.5Metrics of Object Systems128
4.5.1The Analysis for the Complexity of an Object System128
4.5.2Lorenz Metrics130
4.5.3The CK OO Metrics Suite132
4.5.4The Productivity Metrics of Object Systems134
4.6Summary135
Part 2Problem Solving with C++
CHAPTER 5Overview of the Basics of C++
5.1The Simplest C++ Program141
5.2Functions143
5.2.1Function Declaration and Definition143
5.2.2Parameters and Arguments144
5.2.3Constant Reference Parameter147
5.2.4Returned Values148
5.2.5Default Arguments148
5.2.6Viewing Functions as Objects149
5.3Fundamental Objects in C++150
5.3.1Basic Classes and Their Instances151
5.3.2Variable Declaration153
5.3.3Variable Scopes154
5.4Basic Streams for Input and Output156
5.4.1Output Stream156
5.4.2Input Stream157
5.5C++ Control Structures158
5.5.1Sequential Statements158
5.5.2Conditional Structures159
5.5.3Iterative Structures161
5.6Pointers and Memory Allocation165
5.6.1Pointers to Constants167
5.6.2Constant Pointers168
5.6.3Pointers and Arrays168
5.6.4Void Pointers170
5.6.5Allocating Memory172
5.6.6Functions Returning a Pointer175
5.7Summary177
CHAPTER 6Objects and Classes in C++
6.1Project Description181
6.2Analysis and Design182
6.3Class183
6.4Accessing Modifiers184
6.5Member Function Implementation186
6.6Constructors189
6.7Destructor190
6.8Enumeration191
6.9Switch/Case Structure and rand() Function193
6.10Basic Do\|Loop Structure197
6.11Instantiation and Messages198
6.12Standard Input and Output Streams200
6.13Deleting Objects201
6.14The Complete main() Function for the Project 202
6.15Object Copying204
6.16Summary207
CHAPTER 7Inheritance in C++
7.1Project Description211
7.2Analysis and Design212
7.3Base and Derived Classes215
7.3.1Static Variable217
7.4Overriding218
7.5Accessibility of Inherited Members219
7.6Constructor Initializer225
7.7Constructor and Destructor Execution Order226
7.8Creating Instances of Derived Classes227
7.9Create Report on Screen: More on Output Stream229
7.10Function main()232
7.11Running Result of Our Project234
7.12Multiple and Virtual Inheritance236
7.12.1Virtual Base Classes237
7.13Summary238
CHAPTER 8Polymorphism and Overloading in C++
8.1 Project Description: A Self\|Test Program243
8.2Analysis and Design244
8.3Abstract Classes and Virtual Functions247
8.4Derived Classes from an Abstract Class250
8.4.1Derived Abstract Class252
8.5The ExamPaper Class256
8.5.1Polymorphism and Dynamic Binding257
8.5.2Overloading Functions259
8.5.3Other Implementations259
8.6Function main()261
8.6.1Compatibility between Base and Derived Classes263
8.6.2The Main Loop of a Test266
8.6.3The Final Code of main()268
8.7Other Auxiliary Statements271
8.8Sample Running Results272
8.9Other C++ Concepts Relevant to Polymorphism275
8.9.1Polymorphism and Pointers275
8.9.2Virtual Destructors276
8.9.3“this” Pointer278
8.9.4Overloading Functions and Inheritance279
8.10Summary280
CHAPTER 9Templates, Exception Handling and Overloaded
Operators in C++9.1Project Description: A Dictionary Application285
9.2Analysis and Design287
9.3Templates288
9.4Exception Handling292
9.5Function main()298
9.6Auxiliary Statements and Running Results302
9.7Relevant Concepts with Templates305
9.7.1Class Templates and Classes305
9.7.2Function Templates306
9.7.3Overloaded Operators308
9.7.4Overloading a Function Template310
9.8Concepts Relevant with Exception Handling312
9.8.1Unwinding the Exception Stack312
9.8.2Exception with No Catch313
9.8.3Exception within an Exception314
9.8.4Exceptions in Templates316
9.8.5Grouping Exceptions317
9.8.6Re\|throwing an Exception318
9.8.7Exception Interface Specification319
9.9Summary320
CHAPTER 10Container Classes in C++
10.1Project Description: A Student Registration Program325
10.2Analysis and Design326
10.3Linked List327
10.3.1Simple Linked List328
10.3.2Doubly Linked List334
10.4Application of Simple List340
10.5Application of Doubly Linked List341
10.6An Auxiliary Class and Function main()346
10.7Compilation and Execution Results350
10.8Application of Doubly Linked List in a Polymorphic Way353
10.9Summary360
CHAPTER 11Streams and Friends in C++
11.1I/O Operators and Streams366
11.1.1Streams366
11.1.2Output of Basic Objects366
11.1.3Input of Basic Objects368
11.1.4The States of Streams370
11.1.5The Flags and Formats of Streams372
11.1.6Overloaded I/O Operators on Streams377
11.1.7Manipulators381
11.1.8File Streams386
11.1.9String Streams390
11.2Friend391
11.2.1Friend Functions392
11.2.2Friend Classes393
11.2.3Properties of Friends399
11.3Summary400
CHAPTER 12Use of the Standard Library of C++
12.1C++ STL405
12.1.1Containers and Algorithms406
12.1.2Iterators411
12.1.3Other Parts of the STL414
12.2List415
12.2.1The Interfaces of List416
12.2.2The Application of List416
12.2.3The Algorithm Library422
12.2.4Function Objects433
12.3Map434
12.3.1The Interfaces of Map and Pair435
12.3.2Application of Maps436
12.4String443
12.4.1The Interface of String443
12.4.2The Application of String445
12.5Summary448Index450References460 Part 1Principles of Object\|Oriented Programming
CHAPTER 1Introduction to Object\|Oriented Programming
1.1Object\|Oriented Thinking Methodology6
1.1.1Induction and Deduction6
1.1.2Composition and Decomposition7
1.1.3Object\|Orientation as a Thinking Methodology9
1.2Programming Techniques and Concepts11
1.2.1What is Programming?11
1.2.2Abstraction, Information Hiding and Modeling13
1.2.3Procedural Programming and Modules15
1.2.4Encapsulation18
1.2.5Abstract Data Type20
1.3Object\|Oriented Programming21
1.4Other Programming Paradigms24
1.4.1Imperative Programming25
1.4.2Functional Programming25
1.4.3Logic Programming26
1.4.4Relationships between Object\|Oriented Programming and Other
Paradigms27
1.5Object\|Oriented Languages28
1.5.1Simula 6728
1.5.2Smalltalk29
1.5.3C++30
1.5.4Java31
1.5.5C#32
1.5.6Others33
1.6Summary34
CHAPTER 2Object, Classes and Inheritance
2.1Object39
2.1.1Real\|World Object Properties39
2.1.2Virtual Objects41
2.1.3The External and Internal View of an Object42
2.1.4Definition of an Object43
Contents Object\|Oriented Programming in C++: A Project\|Based Approach 2.2Message43
2.2.1The Only Way to Interact43
2.2.2Definition of a Message44
2.2.3Message Categories45
2.2.4Objects in Programming45
2.3Encapsulation and Protocol45
2.4Class46
2.4.1Abstraction46
2.4.2Classification47
2.4.3The Basic View of a Class48
2.4.4Class Definition49
2.4.5Relationships among Classes50
2.4.6The Characteristics of a Class50
2.5Instantiation51
2.6Metaclass53
2.7Inheritance55
2.7.1The Properties of Inheritance55
2.7.2Inheritance Definition56
2.7.3Categories of Inheritance57
2.7.4Naming Conflicts58
2.7.5Precedence Conflicts59
2.8Superclass and Subclass60
2.8.1Subclassing60
2.8.2Modifiability61
2.9Abstract Class61
2.10Summary63
CHAPTER 3Polymorphism, Dynamic Binding, Overloading and
Other Concepts3.1Polymorphism69
3.1.1General Meanings of Polymorphism69
3.1.2Introduction of Polymorphism to Programming Languages70
3.1.3Categories of Polymorphism71
3.1.4The Drawbacks of Polymorphism73
3.2Overloading75
3.2.1Overloading Based on Scopes 75
3.2.2Overloading Based on Type Signatures76
3.3Static and Dynamic Binding77
3.4Overriding79
3.4.1Overriding Variables80
3.4.2Overriding Methods82
3.5Other Object\|Oriented Programming Concepts82
3.5.1Object Interactions83
3.5.2Design Patterns86
3.5.3Objects and Agents95
3.5.4Object\|Orientation and Reusable Components98
3.6Summary100
CHAPTER 4Object\|Oriented Design
4.1Object\|Oriented Software Engineering105
4.2Object\|Oriented Design108
4.2.1OOA vs. OOD108
4.2.2OOD Steps and Tasks110
4.2.3Discussions114
4.3Unified Modeling Language115
4.3.1Use Case Modeling and Use Case Diagrams115
4.3.2Class and Object Diagrams117
4.3.3Association Diagram118
4.3.4Dynamic Modeling121
4.3.5Other Diagrams122
4.4CASE Tools for Object\|Oriented Design123
4.4.1The Basic Architecture of OO ICASE Tools124
4.4.2Some ICASE Tools for OOA/OOD126
4.5Metrics of Object Systems128
4.5.1The Analysis for the Complexity of an Object System128
4.5.2Lorenz Metrics130
4.5.3The CK OO Metrics Suite132
4.5.4The Productivity Metrics of Object Systems134
4.6Summary135
Part 2Problem Solving with C++
CHAPTER 5Overview of the Basics of C++
5.1The Simplest C++ Program141
5.2Functions143
5.2.1Function Declaration and Definition143
5.2.2Parameters and Arguments144
5.2.3Constant Reference Parameter147
5.2.4Returned Values148
5.2.5Default Arguments148
5.2.6Viewing Functions as Objects149
5.3Fundamental Objects in C++150
5.3.1Basic Classes and Their Instances151
5.3.2Variable Declaration153
5.3.3Variable Scopes154
5.4Basic Streams for Input and Output156
5.4.1Output Stream156
5.4.2Input Stream157
5.5C++ Control Structures158
5.5.1Sequential Statements158
5.5.2Conditional Structures159
5.5.3Iterative Structures161
5.6Pointers and Memory Allocation165
5.6.1Pointers to Constants167
5.6.2Constant Pointers168
5.6.3Pointers and Arrays168
5.6.4Void Pointers170
5.6.5Allocating Memory172
5.6.6Functions Returning a Pointer175
5.7Summary177
CHAPTER 6Objects and Classes in C++
6.1Project Description181
6.2Analysis and Design182
6.3Class183
6.4Accessing Modifiers184
6.5Member Function Implementation186
6.6Constructors189
6.7Destructor190
6.8Enumeration191
6.9Switch/Case Structure and rand() Function193
6.10Basic Do\|Loop Structure197
6.11Instantiation and Messages198
6.12Standard Input and Output Streams200
6.13Deleting Objects201
6.14The Complete main() Function for the Project 202
6.15Object Copying204
6.16Summary207
CHAPTER 7Inheritance in C++
7.1Project Description211
7.2Analysis and Design212
7.3Base and Derived Classes215
7.3.1Static Variable217
7.4Overriding218
7.5Accessibility of Inherited Members219
7.6Constructor Initializer225
7.7Constructor and Destructor Execution Order226
7.8Creating Instances of Derived Classes227
7.9Create Report on Screen: More on Output Stream229
7.10Function main()232
7.11Running Result of Our Project234
7.12Multiple and Virtual Inheritance236
7.12.1Virtual Base Classes237
7.13Summary238
CHAPTER 8Polymorphism and Overloading in C++
8.1 Project Description: A Self\|Test Program243
8.2Analysis and Design244
8.3Abstract Classes and Virtual Functions247
8.4Derived Classes from an Abstract Class250
8.4.1Derived Abstract Class252
8.5The ExamPaper Class256
8.5.1Polymorphism and Dynamic Binding257
8.5.2Overloading Functions259
8.5.3Other Implementations259
8.6Function main()261
8.6.1Compatibility between Base and Derived Classes263
8.6.2The Main Loop of a Test266
8.6.3The Final Code of main()268
8.7Other Auxiliary Statements271
8.8Sample Running Results272
8.9Other C++ Concepts Relevant to Polymorphism275
8.9.1Polymorphism and Pointers275
8.9.2Virtual Destructors276
8.9.3“this” Pointer278
8.9.4Overloading Functions and Inheritance279
8.10Summary280
CHAPTER 9Templates, Exception Handling and Overloaded
Operators in C++9.1Project Description: A Dictionary Application285
9.2Analysis and Design287
9.3Templates288
9.4Exception Handling292
9.5Function main()298
9.6Auxiliary Statements and Running Results302
9.7Relevant Concepts with Templates305
9.7.1Class Templates and Classes305
9.7.2Function Templates306
9.7.3Overloaded Operators308
9.7.4Overloading a Function Template310
9.8Concepts Relevant with Exception Handling312
9.8.1Unwinding the Exception Stack312
9.8.2Exception with No Catch313
9.8.3Exception within an Exception314
9.8.4Exceptions in Templates316
9.8.5Grouping Exceptions317
9.8.6Re\|throwing an Exception318
9.8.7Exception Interface Specification319
9.9Summary320
CHAPTER 10Container Classes in C++
10.1Project Description: A Student Registration Program325
10.2Analysis and Design326
10.3Linked List327
10.3.1Simple Linked List328
10.3.2Doubly Linked List334
10.4Application of Simple List340
10.5Application of Doubly Linked List341
10.6An Auxiliary Class and Function main()346
10.7Compilation and Execution Results350
10.8Application of Doubly Linked List in a Polymorphic Way353
10.9Summary360
CHAPTER 11Streams and Friends in C++
11.1I/O Operators and Streams366
11.1.1Streams366
11.1.2Output of Basic Objects366
11.1.3Input of Basic Objects368
11.1.4The States of Streams370
11.1.5The Flags and Formats of Streams372
11.1.6Overloaded I/O Operators on Streams377
11.1.7Manipulators381
11.1.8File Streams386
11.1.9String Streams390
11.2Friend391
11.2.1Friend Functions392
11.2.2Friend Classes393
11.2.3Properties of Friends399
11.3Summary400
CHAPTER 12Use of the Standard Library of C++
12.1C++ STL405
12.1.1Containers and Algorithms406
12.1.2Iterators411
12.1.3Other Parts of the STL414
12.2List415
12.2.1The Interfaces of List416
12.2.2The Application of List416
12.2.3The Algorithm Library422
12.2.4Function Objects433
12.3Map434
12.3.1The Interfaces of Map and Pair435
12.3.2Application of Maps436
12.4String443
12.4.1The Interface of String443
12.4.2The Application of String445
12.5Summary448Index450References460
CHAPTER 1Introduction to Object\|Oriented Programming
1.1Object\|Oriented Thinking Methodology6
1.1.1Induction and Deduction6
1.1.2Composition and Decomposition7
1.1.3Object\|Orientation as a Thinking Methodology9
1.2Programming Techniques and Concepts11
1.2.1What is Programming?11
1.2.2Abstraction, Information Hiding and Modeling13
1.2.3Procedural Programming and Modules15
1.2.4Encapsulation18
1.2.5Abstract Data Type20
1.3Object\|Oriented Programming21
1.4Other Programming Paradigms24
1.4.1Imperative Programming25
1.4.2Functional Programming25
1.4.3Logic Programming26
1.4.4Relationships between Object\|Oriented Programming and Other
Paradigms27
1.5Object\|Oriented Languages28
1.5.1Simula 6728
1.5.2Smalltalk29
1.5.3C++30
1.5.4Java31
1.5.5C#32
1.5.6Others33
1.6Summary34
CHAPTER 2Object, Classes and Inheritance
2.1Object39
2.1.1Real\|World Object Properties39
2.1.2Virtual Objects41
2.1.3The External and Internal View of an Object42
2.1.4Definition of an Object43
Contents Object\|Oriented Programming in C++: A Project\|Based Approach 2.2Message43
2.2.1The Only Way to Interact43
2.2.2Definition of a Message44
2.2.3Message Categories45
2.2.4Objects in Programming45
2.3Encapsulation and Protocol45
2.4Class46
2.4.1Abstraction46
2.4.2Classification47
2.4.3The Basic View of a Class48
2.4.4Class Definition49
2.4.5Relationships among Classes50
2.4.6The Characteristics of a Class50
2.5Instantiation51
2.6Metaclass53
2.7Inheritance55
2.7.1The Properties of Inheritance55
2.7.2Inheritance Definition56
2.7.3Categories of Inheritance57
2.7.4Naming Conflicts58
2.7.5Precedence Conflicts59
2.8Superclass and Subclass60
2.8.1Subclassing60
2.8.2Modifiability61
2.9Abstract Class61
2.10Summary63
CHAPTER 3Polymorphism, Dynamic Binding, Overloading and
Other Concepts3.1Polymorphism69
3.1.1General Meanings of Polymorphism69
3.1.2Introduction of Polymorphism to Programming Languages70
3.1.3Categories of Polymorphism71
3.1.4The Drawbacks of Polymorphism73
3.2Overloading75
3.2.1Overloading Based on Scopes 75
3.2.2Overloading Based on Type Signatures76
3.3Static and Dynamic Binding77
3.4Overriding79
3.4.1Overriding Variables80
3.4.2Overriding Methods82
3.5Other Object\|Oriented Programming Concepts82
3.5.1Object Interactions83
3.5.2Design Patterns86
3.5.3Objects and Agents95
3.5.4Object\|Orientation and Reusable Components98
3.6Summary100
CHAPTER 4Object\|Oriented Design
4.1Object\|Oriented Software Engineering105
4.2Object\|Oriented Design108
4.2.1OOA vs. OOD108
4.2.2OOD Steps and Tasks110
4.2.3Discussions114
4.3Unified Modeling Language115
4.3.1Use Case Modeling and Use Case Diagrams115
4.3.2Class and Object Diagrams117
4.3.3Association Diagram118
4.3.4Dynamic Modeling121
4.3.5Other Diagrams122
4.4CASE Tools for Object\|Oriented Design123
4.4.1The Basic Architecture of OO ICASE Tools124
4.4.2Some ICASE Tools for OOA/OOD126
4.5Metrics of Object Systems128
4.5.1The Analysis for the Complexity of an Object System128
4.5.2Lorenz Metrics130
4.5.3The CK OO Metrics Suite132
4.5.4The Productivity Metrics of Object Systems134
4.6Summary135
Part 2Problem Solving with C++
CHAPTER 5Overview of the Basics of C++
5.1The Simplest C++ Program141
5.2Functions143
5.2.1Function Declaration and Definition143
5.2.2Parameters and Arguments144
5.2.3Constant Reference Parameter147
5.2.4Returned Values148
5.2.5Default Arguments148
5.2.6Viewing Functions as Objects149
5.3Fundamental Objects in C++150
5.3.1Basic Classes and Their Instances151
5.3.2Variable Declaration153
5.3.3Variable Scopes154
5.4Basic Streams for Input and Output156
5.4.1Output Stream156
5.4.2Input Stream157
5.5C++ Control Structures158
5.5.1Sequential Statements158
5.5.2Conditional Structures159
5.5.3Iterative Structures161
5.6Pointers and Memory Allocation165
5.6.1Pointers to Constants167
5.6.2Constant Pointers168
5.6.3Pointers and Arrays168
5.6.4Void Pointers170
5.6.5Allocating Memory172
5.6.6Functions Returning a Pointer175
5.7Summary177
CHAPTER 6Objects and Classes in C++
6.1Project Description181
6.2Analysis and Design182
6.3Class183
6.4Accessing Modifiers184
6.5Member Function Implementation186
6.6Constructors189
6.7Destructor190
6.8Enumeration191
6.9Switch/Case Structure and rand() Function193
6.10Basic Do\|Loop Structure197
6.11Instantiation and Messages198
6.12Standard Input and Output Streams200
6.13Deleting Objects201
6.14The Complete main() Function for the Project 202
6.15Object Copying204
6.16Summary207
CHAPTER 7Inheritance in C++
7.1Project Description211
7.2Analysis and Design212
7.3Base and Derived Classes215
7.3.1Static Variable217
7.4Overriding218
7.5Accessibility of Inherited Members219
7.6Constructor Initializer225
7.7Constructor and Destructor Execution Order226
7.8Creating Instances of Derived Classes227
7.9Create Report on Screen: More on Output Stream229
7.10Function main()232
7.11Running Result of Our Project234
7.12Multiple and Virtual Inheritance236
7.12.1Virtual Base Classes237
7.13Summary238
CHAPTER 8Polymorphism and Overloading in C++
8.1 Project Description: A Self\|Test Program243
8.2Analysis and Design244
8.3Abstract Classes and Virtual Functions247
8.4Derived Classes from an Abstract Class250
8.4.1Derived Abstract Class252
8.5The ExamPaper Class256
8.5.1Polymorphism and Dynamic Binding257
8.5.2Overloading Functions259
8.5.3Other Implementations259
8.6Function main()261
8.6.1Compatibility between Base and Derived Classes263
8.6.2The Main Loop of a Test266
8.6.3The Final Code of main()268
8.7Other Auxiliary Statements271
8.8Sample Running Results272
8.9Other C++ Concepts Relevant to Polymorphism275
8.9.1Polymorphism and Pointers275
8.9.2Virtual Destructors276
8.9.3“this” Pointer278
8.9.4Overloading Functions and Inheritance279
8.10Summary280
CHAPTER 9Templates, Exception Handling and Overloaded
Operators in C++9.1Project Description: A Dictionary Application285
9.2Analysis and Design287
9.3Templates288
9.4Exception Handling292
9.5Function main()298
9.6Auxiliary Statements and Running Results302
9.7Relevant Concepts with Templates305
9.7.1Class Templates and Classes305
9.7.2Function Templates306
9.7.3Overloaded Operators308
9.7.4Overloading a Function Template310
9.8Concepts Relevant with Exception Handling312
9.8.1Unwinding the Exception Stack312
9.8.2Exception with No Catch313
9.8.3Exception within an Exception314
9.8.4Exceptions in Templates316
9.8.5Grouping Exceptions317
9.8.6Re\|throwing an Exception318
9.8.7Exception Interface Specification319
9.9Summary320
CHAPTER 10Container Classes in C++
10.1Project Description: A Student Registration Program325
10.2Analysis and Design326
10.3Linked List327
10.3.1Simple Linked List328
10.3.2Doubly Linked List334
10.4Application of Simple List340
10.5Application of Doubly Linked List341
10.6An Auxiliary Class and Function main()346
10.7Compilation and Execution Results350
10.8Application of Doubly Linked List in a Polymorphic Way353
10.9Summary360
CHAPTER 11Streams and Friends in C++
11.1I/O Operators and Streams366
11.1.1Streams366
11.1.2Output of Basic Objects366
11.1.3Input of Basic Objects368
11.1.4The States of Streams370
11.1.5The Flags and Formats of Streams372
11.1.6Overloaded I/O Operators on Streams377
11.1.7Manipulators381
11.1.8File Streams386
11.1.9String Streams390
11.2Friend391
11.2.1Friend Functions392
11.2.2Friend Classes393
11.2.3Properties of Friends399
11.3Summary400
CHAPTER 12Use of the Standard Library of C++
12.1C++ STL405
12.1.1Containers and Algorithms406
12.1.2Iterators411
12.1.3Other Parts of the STL414
12.2List415
12.2.1The Interfaces of List416
12.2.2The Application of List416
12.2.3The Algorithm Library422
12.2.4Function Objects433
12.3Map434
12.3.1The Interfaces of Map and Pair435
12.3.2Application of Maps436
12.4String443
12.4.1The Interface of String443
12.4.2The Application of String445
12.5Summary448Index450References460 Part 1Principles of Object\|Oriented Programming
CHAPTER 1Introduction to Object\|Oriented Programming
1.1Object\|Oriented Thinking Methodology6
1.1.1Induction and Deduction6
1.1.2Composition and Decomposition7
1.1.3Object\|Orientation as a Thinking Methodology9
1.2Programming Techniques and Concepts11
1.2.1What is Programming?11
1.2.2Abstraction, Information Hiding and Modeling13
1.2.3Procedural Programming and Modules15
1.2.4Encapsulation18
1.2.5Abstract Data Type20
1.3Object\|Oriented Programming21
1.4Other Programming Paradigms24
1.4.1Imperative Programming25
1.4.2Functional Programming25
1.4.3Logic Programming26
1.4.4Relationships between Object\|Oriented Programming and Other
Paradigms27
1.5Object\|Oriented Languages28
1.5.1Simula 6728
1.5.2Smalltalk29
1.5.3C++30
1.5.4Java31
1.5.5C#32
1.5.6Others33
1.6Summary34
CHAPTER 2Object, Classes and Inheritance
2.1Object39
2.1.1Real\|World Object Properties39
2.1.2Virtual Objects41
2.1.3The External and Internal View of an Object42
2.1.4Definition of an Object43
Contents Object\|Oriented Programming in C++: A Project\|Based Approach 2.2Message43
2.2.1The Only Way to Interact43
2.2.2Definition of a Message44
2.2.3Message Categories45
2.2.4Objects in Programming45
2.3Encapsulation and Protocol45
2.4Class46
2.4.1Abstraction46
2.4.2Classification47
2.4.3The Basic View of a Class48
2.4.4Class Definition49
2.4.5Relationships among Classes50
2.4.6The Characteristics of a Class50
2.5Instantiation51
2.6Metaclass53
2.7Inheritance55
2.7.1The Properties of Inheritance55
2.7.2Inheritance Definition56
2.7.3Categories of Inheritance57
2.7.4Naming Conflicts58
2.7.5Precedence Conflicts59
2.8Superclass and Subclass60
2.8.1Subclassing60
2.8.2Modifiability61
2.9Abstract Class61
2.10Summary63
CHAPTER 3Polymorphism, Dynamic Binding, Overloading and
Other Concepts3.1Polymorphism69
3.1.1General Meanings of Polymorphism69
3.1.2Introduction of Polymorphism to Programming Languages70
3.1.3Categories of Polymorphism71
3.1.4The Drawbacks of Polymorphism73
3.2Overloading75
3.2.1Overloading Based on Scopes 75
3.2.2Overloading Based on Type Signatures76
3.3Static and Dynamic Binding77
3.4Overriding79
3.4.1Overriding Variables80
3.4.2Overriding Methods82
3.5Other Object\|Oriented Programming Concepts82
3.5.1Object Interactions83
3.5.2Design Patterns86
3.5.3Objects and Agents95
3.5.4Object\|Orientation and Reusable Components98
3.6Summary100
CHAPTER 4Object\|Oriented Design
4.1Object\|Oriented Software Engineering105
4.2Object\|Oriented Design108
4.2.1OOA vs. OOD108
4.2.2OOD Steps and Tasks110
4.2.3Discussions114
4.3Unified Modeling Language115
4.3.1Use Case Modeling and Use Case Diagrams115
4.3.2Class and Object Diagrams117
4.3.3Association Diagram118
4.3.4Dynamic Modeling121
4.3.5Other Diagrams122
4.4CASE Tools for Object\|Oriented Design123
4.4.1The Basic Architecture of OO ICASE Tools124
4.4.2Some ICASE Tools for OOA/OOD126
4.5Metrics of Object Systems128
4.5.1The Analysis for the Complexity of an Object System128
4.5.2Lorenz Metrics130
4.5.3The CK OO Metrics Suite132
4.5.4The Productivity Metrics of Object Systems134
4.6Summary135
Part 2Problem Solving with C++
CHAPTER 5Overview of the Basics of C++
5.1The Simplest C++ Program141
5.2Functions143
5.2.1Function Declaration and Definition143
5.2.2Parameters and Arguments144
5.2.3Constant Reference Parameter147
5.2.4Returned Values148
5.2.5Default Arguments148
5.2.6Viewing Functions as Objects149
5.3Fundamental Objects in C++150
5.3.1Basic Classes and Their Instances151
5.3.2Variable Declaration153
5.3.3Variable Scopes154
5.4Basic Streams for Input and Output156
5.4.1Output Stream156
5.4.2Input Stream157
5.5C++ Control Structures158
5.5.1Sequential Statements158
5.5.2Conditional Structures159
5.5.3Iterative Structures161
5.6Pointers and Memory Allocation165
5.6.1Pointers to Constants167
5.6.2Constant Pointers168
5.6.3Pointers and Arrays168
5.6.4Void Pointers170
5.6.5Allocating Memory172
5.6.6Functions Returning a Pointer175
5.7Summary177
CHAPTER 6Objects and Classes in C++
6.1Project Description181
6.2Analysis and Design182
6.3Class183
6.4Accessing Modifiers184
6.5Member Function Implementation186
6.6Constructors189
6.7Destructor190
6.8Enumeration191
6.9Switch/Case Structure and rand() Function193
6.10Basic Do\|Loop Structure197
6.11Instantiation and Messages198
6.12Standard Input and Output Streams200
6.13Deleting Objects201
6.14The Complete main() Function for the Project 202
6.15Object Copying204
6.16Summary207
CHAPTER 7Inheritance in C++
7.1Project Description211
7.2Analysis and Design212
7.3Base and Derived Classes215
7.3.1Static Variable217
7.4Overriding218
7.5Accessibility of Inherited Members219
7.6Constructor Initializer225
7.7Constructor and Destructor Execution Order226
7.8Creating Instances of Derived Classes227
7.9Create Report on Screen: More on Output Stream229
7.10Function main()232
7.11Running Result of Our Project234
7.12Multiple and Virtual Inheritance236
7.12.1Virtual Base Classes237
7.13Summary238
CHAPTER 8Polymorphism and Overloading in C++
8.1 Project Description: A Self\|Test Program243
8.2Analysis and Design244
8.3Abstract Classes and Virtual Functions247
8.4Derived Classes from an Abstract Class250
8.4.1Derived Abstract Class252
8.5The ExamPaper Class256
8.5.1Polymorphism and Dynamic Binding257
8.5.2Overloading Functions259
8.5.3Other Implementations259
8.6Function main()261
8.6.1Compatibility between Base and Derived Classes263
8.6.2The Main Loop of a Test266
8.6.3The Final Code of main()268
8.7Other Auxiliary Statements271
8.8Sample Running Results272
8.9Other C++ Concepts Relevant to Polymorphism275
8.9.1Polymorphism and Pointers275
8.9.2Virtual Destructors276
8.9.3“this” Pointer278
8.9.4Overloading Functions and Inheritance279
8.10Summary280
CHAPTER 9Templates, Exception Handling and Overloaded
Operators in C++9.1Project Description: A Dictionary Application285
9.2Analysis and Design287
9.3Templates288
9.4Exception Handling292
9.5Function main()298
9.6Auxiliary Statements and Running Results302
9.7Relevant Concepts with Templates305
9.7.1Class Templates and Classes305
9.7.2Function Templates306
9.7.3Overloaded Operators308
9.7.4Overloading a Function Template310
9.8Concepts Relevant with Exception Handling312
9.8.1Unwinding the Exception Stack312
9.8.2Exception with No Catch313
9.8.3Exception within an Exception314
9.8.4Exceptions in Templates316
9.8.5Grouping Exceptions317
9.8.6Re\|throwing an Exception318
9.8.7Exception Interface Specification319
9.9Summary320
CHAPTER 10Container Classes in C++
10.1Project Description: A Student Registration Program325
10.2Analysis and Design326
10.3Linked List327
10.3.1Simple Linked List328
10.3.2Doubly Linked List334
10.4Application of Simple List340
10.5Application of Doubly Linked List341
10.6An Auxiliary Class and Function main()346
10.7Compilation and Execution Results350
10.8Application of Doubly Linked List in a Polymorphic Way353
10.9Summary360
CHAPTER 11Streams and Friends in C++
11.1I/O Operators and Streams366
11.1.1Streams366
11.1.2Output of Basic Objects366
11.1.3Input of Basic Objects368
11.1.4The States of Streams370
11.1.5The Flags and Formats of Streams372
11.1.6Overloaded I/O Operators on Streams377
11.1.7Manipulators381
11.1.8File Streams386
11.1.9String Streams390
11.2Friend391
11.2.1Friend Functions392
11.2.2Friend Classes393
11.2.3Properties of Friends399
11.3Summary400
CHAPTER 12Use of the Standard Library of C++
12.1C++ STL405
12.1.1Containers and Algorithms406
12.1.2Iterators411
12.1.3Other Parts of the STL414
12.2List415
12.2.1The Interfaces of List416
12.2.2The Application of List416
12.2.3The Algorithm Library422
12.2.4Function Objects433
12.3Map434
12.3.1The Interfaces of Map and Pair435
12.3.2Application of Maps436
12.4String443
12.4.1The Interface of String443
12.4.2The Application of String445
12.5Summary448Index450References460
猜您喜欢