书籍详情
C++程序设计(英文版·第五版)
作者:(美)代特尔 等著
出版社:人民邮电出版社
出版时间:2006-01-01
ISBN:9787115141514
定价:¥59.00
购买这本书可以去
内容简介
C++是最流行的面向对象程序设计语言之一。本书以全球使用最广泛的C++教材C++HowtoProgram最新版为基础,涵盖了类与对象、控制语句、函数与递归、数组与向量、指针与基于指针的字符串、操作符重载、面向对象编程(继承与多态)等核心内容。本书采用了循序渐进的“类和对象提早介绍方法”。书中除了含有大量的自测题及自测题答案外,还包含了几个大的集成案例分析:GradeBook类、Time类以及Employee类。本书非常适合国内教学情况,可作为程序设计语言课程的教材,对于程序设计人员也是很好的技术参考书。采用DEITEL®LIVE-CODE方式的权威C++语言教材最新版!采用UML2介绍面向对象程序设计C++是最流行的面向对象程序设计语言之一。本书以全球使用最广泛的C++教材C++HowtoProgram最新版为基础,涵盖了核心的前13章内容,非常适合国内教学情况。书中采用了循序渐进的“类和对象优先介绍方法”。“优先介绍类和对象的方法非常好。书中LIVE-CODE示例与详细图形的结合,直观地阐明了C++的概念,非常独特。”——EarlLaBatt,新罕布什尔大学“新版标志着Deitel的C++系列图书的教学法又前进了重要一步。优先介绍类和对象符合当前的软件开发人员教育思路。书中的编码规范非常缜密,而且遵循最高的程序设计标准。”——RicHeishman,北弗吉尼亚社区学院“Deitel总能清晰地解释概念和思想,使学生全面理解语言和软件开发,我对此一直印象深刻。”——KarenArlien,Bismarck州立学院“本书在同类图书中出类拔萃。它是采用“对象优先”方法介绍C++的典范,初学者非常容易接受。”——GavinOsborne,Saskatchewan应用科学和技术学院“提早将UML介绍给学生是一个非常好的想法。”——RaymondStephenson,微软公司“多态这一部分讲得非常好,对编译器如何在幕后实现多态的解释尤其精彩。我真希望自己当学生时也能读到对其中数据结构这么清晰的阐述。”——EdJames-Beckham,Borland公司“我真的很喜欢书中完整的LIVE-CODE示例——它们为学生创建自己的代码提供了很好的起点。”——WilliamHonig,Loyola大学“书中集成的GradeBook案例分析真不错!它所展示的对象很有用,可以应用到学生的生活中。”——KarenArlien,Bismarck州立学院“在这本语言教材中,Deitel再次展示了他的大师风范:易于学习,内容全面,总是将学生读者的所需所想牢记在心。”——BrianLarson,Modesto专科学院本书完整地讲述了C++面向对象程序设计,其中包含了几个大的集成案例分析:GradeBook类(第3~7章)、Time类(第9章中的3小节)以及Employee类(第12~13章)。HarveyM.Deitel博士和PaulJ.Deitel是Deitel&Associates公司的创始人,该公司是国际上知名的企业培训和内容创建机构,专长是C++、Java、C、C#、VisualBasic.NET、VisualC++.NET、XML、Python、Perl、Internet、Web和对象技术。Deitel父子是许多畅销教材的作者,包括C++HowtoProgram,5/e、JavaHowtoProgram,6/e、Internet&WorldWideWebHowtoProgram,3/e和CHowtoProgram,4/e。本书的下载资源包括代码示例以及提供给教师、学生和专业人员的相关信息,下载站点为www.deitel.com和www.prenhall.com/deitel。作者的联系方式:deitel@deitel.com。获取有关DEITEL®DIVEINTO®SERIES提供的全球公司现场培训服务的相关信息以及订阅免费的DEITEL®BUZZONLINE电子简讯,请访问www.deitel.com。本书的习题和配套光盘的内容请从www.turingbook.com下载。封面正面文字:优先介绍类/对象/面向对象类、对象和封装继承多态性基础流I/O、类型和操作符控制语句和函数数组和向量指针和引用string类和C风格字符串操作符重载字符操作递归简介查找和排序简介UMLTM2确定类、属性和操作类图活动图集成的OOP案例分析GradeBook类Time类EmployeePayroll类
作者简介
作者:DEITELHarveyM.Deitel,世界一流的计算机科学教员和研计会演讲人;PaulJ.Deitel,国际知名的教育家HarveyM.Deitel博士是Deitel&Associates公司总裁,有着40余年计算机领域的工作经验,进行了大量深入的教学研究,是世界一流的计算机科学教员和研计会演讲人。HarveyM.Deitel持有麻省理工学院学士、硕士学位和波士顿大学博士学位。他曾经在IBM和MIT的虚拟内存操作系统项目中从事研究工作,开发出在很多系统中广泛实现的技术。他还有20多年大学教学经验,取得过“教育特别津贴”。也是全球知名的计算机教材作者。其作品已被翻译成日、俄、中文(繁简)、韩、法、西班牙等语言。PaulJ.Deitel是Deitel&Associates公司执行副总裁,是麻省理工学院Sloun管理学校的毕业生。主修信息技术,通过Deitel&Associates公司他已经为DigitalEquipmentCorporation......等多家公司的客户提供Java、C和C++课程的教学活动,并曾为计算机协会波士顿分会授Java和C++语言,还通过卫星直播Java课程。VisualBasic.NET2003大学简明教程:实例程序设计>>更多作品
目录
Contents
1 Introduction 1
1.1 Introduction 1
1.2 History of C and C++ 2
1.3 C++ Standard Library 2
1.4 Key Software Trend: Object Technology 3
1.5 Typical C++ Development Environment 4
1.6 Notes About C++ and Small C++ How to Program, 5/e 7
1.7 Test-Driving a C++ Application 7
1.8 Introduction to Object Technology and the UML 12
1.9 Wrap-Up 17
1.10 Web Resources 17
2 Introduction to C++ Programming 21
2.1 Introduction 21
2.2 First Program in C++: Printing a Line of Text 21
2.3 Modifying Our First C++ Program 24
2.4 Another C++ Program: Adding Integers 25
2.5 Memory Concepts 28
2.6 Arithmetic 29
2.7 Decision Making: Equality and Relational Operators 33
2.8 Wrap-Up 36
3 Introduction to Classes and Objects 41
3.1 Introduction 41
3.2 Classes, Objects, Member Functions and Data Members 41
3.3 Overview of the Chapter Examples 42
3.4 Defining a Class with a Member Function 43
3.5 Defining a Member Function with a Parameter 45
3.6 Data Members, set Functions and get Functions 48
3.7 Initializing Objects with Constructors 54
3.8 Placing a Class in a Separate File for Reusability 57
3.9 Separating Interface from Implementation 60
3.10 Validating Data with set Functions 65
3.11 Wrap-Up 69
Contents
c++Book.book Page 1 Wednesday, November 9, 2005 1:35 PM
2 Contents
4 Control Statements: Part 1 73
4.1 Introduction 73
4.2 Algorithms 73
4.3 Pseudocode 73
4.4 Control Structures 74
4.5 if Selection Statement 78
4.6 if…else Double-Selection Statement 79
4.7 while Repetition Statement 83
4.8 Formulating Algorithms: Counter-Controlled Repetition 84
4.9 Formulating Algorithms: Sentinel-Controlled Repetition 89
4.10 Formulating Algorithms: Nested Control Statements 98
4.11 Assignment Operators 102
4.12 Increment and Decrement Operators 103
4.13 Wrap-Up 105
5 Control Statements: Part 2 111
5.1 Introduction 111
5.2 Essentials of Counter-Controlled Repetition 111
5.3 for Repetition Statement 113
5.4 Examples Using the for Statement 117
5.5 do…while Repetition Statement 120
5.6 switch Multiple-Selection Statement 122
5.7 break and continue Statements 130
5.8 Logical Operators 132
5.9 Confusing Equality (==) and Assignment (=) Operators 135
5.10 Structured Programming Summary 136
5.11 Wrap-Up 141
6 Functions and an Introduction to Recursion 145
6.1 Introduction 145
6.2 Program Components in C++ 145
6.3 Math Library Functions 147
6.4 Function Definitions with Multiple Parameters 148
6.5 Function Prototypes and Argument Coercion 152
6.6 C++ Standard Library Header Files 154
6.7 Case Study: Random Number Generation 155
6.8 Case Study: Game of Chance and Introducing enum 160
6.9 Storage Classes 163
6.10 Scope Rules 166
6.11 Function Call Stack and Activation Records 168
6.12 Functions with Empty Parameter Lists 172
6.13 Inline Functions 173
6.14 References and Reference Parameters 174
6.15 Default Arguments 178
6.16 Unary Scope Resolution Operator 180
c++Book.book Page 2 Wednesday, November 9, 2005 1:35 PM
Contents 3
6.17 Function Overloading 181
6.18 Function Templates 183
6.19 Recursion 185
6.20 Example Using Recursion: Fibonacci Series 188
6.21 Recursion vs. Iteration 191
6.22 Wrap-Up 193
7 Arrays and Vectors 203
7.1 Introduction 203
7.2 Arrays 203
7.3 Declaring Arrays 205
7.4 Examples Using Arrays 205
7.5 Passing Arrays to Functions 219
7.6 Case Study: Class GradeBook Using an Array to Store Grades 223
7.7 Searching Arrays with Linear Search 228
7.8 Sorting Arrays with Insertion Sort 230
7.9 Multidimensional Arrays 232
7.10 Case Study: Class GradeBook Using a Two-Dimensional Array 234
7.11 Introduction to C++ Standard Library Class Template vector 240
7.12 Wrap-Up 244
8 Pointers and Pointer-Based Strings 249
8.1 Introduction 249
8.2 Pointer Variable Declarations and Initialization 249
8.3 Pointer Operators 250
8.4 Passing Arguments to Functions by Reference with Pointers 253
8.5 Using const with Pointers 256
8.6 Selection Sort Using Pass-by-Reference 262
8.7 sizeof Operators 265
8.8 Pointer Expressions and Pointer Arithmetic 267
8.9 Relationship Between Pointers and Arrays 270
8.10 Arrays of Pointers 273
8.11 Case Study: Card Shuffling and Dealing Simulation 274
8.12 Function Pointers 279
8.13 Introduction to Pointer-Based String Processing 283
8.13.1 Fundamentals of Characters and Pointer-Based Strings 283
8.13.2 String Manipulation Functions of the String-Handling Library 285
8.14 Wrap-Up 292
9 Classes: A Deeper Look, Part 1 299
9.1 Introduction 299
9.2 Time Class Case Study 299
9.3 Class Scope and Accessing Class Members 305
9.4 Separating Interface from Implementation 307
c++Book.book Page 3 Wednesday, November 9, 2005 1:35 PM
4 Contents
9.5 Access Functions and Utility Functions 307
9.6 Time Class Case Study: Constructors with Default Arguments 310
9.7 Destructors 314
9.8 When Constructors and Destructors Are Called 315
9.9 Time Class Case Study:A Subtle Trap—Returning a Reference to a private
Data Member 318
9.10 Default Memberwise Assignment 320
9.11 Software Reusability 322
9.12 Wrap-Up 322
10 Classes: A Deeper Look, Part 2 327
10.1 Introduction 327
10.2 const (Constant) Objects and const Member Functions 327
10.3 Composition: Objects as Members of Classes 336
10.4 friend Functions and friend Classes 341
10.5 Using the this Pointer 345
10.6 Dynamic Memory Management with Operators new and delete 349
10.7 static Class Members 351
10.8 Data Abstraction and Information Hiding 356
10.8.1 Example: Array Abstract Data Type 357
10.8.2 Example: String Abstract Data Type 357
10.8.3 Example: Queue Abstract Data Type 357
10.9 Container Classes and Iterators 358
10.10 Proxy Classes 358
10.11 Wrap-Up 361
11 Operator Overloading; String and Array Objects 365
11.1 Introduction 365
11.2 Fundamentals of Operator Overloading 365
11.3 Restrictions on Operator Overloading 366
11.4 Operator Functions as Class Members vs. Global Functions 368
11.5 Overloading Stream Insertion and Stream Extraction Operators 369
11.6 Overloading Unary Operators 372
11.7 Overloading Binary Operators 372
11.8 Case Study: Array Class 373
11.9 Converting between Types 383
11.10 Case Study: String Class 384
11.11 Overloading ++ and -- 394
11.12 Case Study: A Date Class 395
11.13 Standard Library Class string 399
11.14 explicit Constructors 402
11.15 Wrap-Up 405
c++Book.book Page 4 Wednesday, November 9, 2005 1:35 PM
Contents 5
12 Object-Oriented Programming: Inheritance 409
12.1 Introduction 409
12.2 Base Classes and Derived Classes 410
12.3 protected Members 412
12.4 Relationship between Base Classes and Derived Classes 412
12.4.1 Creating and Using a CommissionEmployee Class 413
12.4.2 Creating a BasePlusCommissionEmployee Class Without Using Inheritance 417
12.4.3 Creating a CommissionEmployee–BasePlusCommissionEmployee Inheritance
Hierarchy 422
12.4.4 CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy
Using protected Data 426
12.4.5 CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy
Using private Data 435
12.5 Constructors and Destructors in Derived Classes 439
12.6 public, protected and private Inheritance 446
12.7 Software Engineering with Inheritance 446
12.8 Wrap-Up 448
13 Object-Oriented Programming: Polymorphism 451
13.1 Introduction 451
13.2 Polymorphism Examples 452
13.3 Relationships Among Objects in an Inheritance Hierarchy 453
13.3.1 Invoking Base-Class Functions from Derived-Class Objects 453
13.3.2 Aiming Derived-Class Pointers at Base-Class Objects 459
13.3.3 Derived-Class Member-Function Calls via Base-Class Pointers 460
13.3.4 Virtual Functions 462
13.3.5 Summary of the Allowed Assignments Between Base-Class and Derived-Class
Objects and Pointers 467
13.4 Type Fields and switch Statements 468
13.5 Abstract Classes and Pure virtual Functions 468
13.6 Case Study: Payroll System Using Polymorphism 470
13.6.1 Creating Abstract Base Class Employee 471
13.6.2 Creating Concrete Derived Class SalariedEmployee 474
13.6.3 Creating Concrete Derived Class HourlyEmployee 476
13.6.4 Creating Concrete Derived Class CommissionEmployee 478
13.6.5 Creating Indirect Concrete Derived Class BasePlusCommissionEmployee 480
13.6.6 Demonstrating Polymorphic Processing 481
13.7 (Optional) Polymorphism, Virtual Functions and Dynamic Binding “Under the Hood” 485
13.8 Case Study: Payroll System 488
13.9 Virtual Destructors 491
13.10 Wrap-Up 492
c++Book.book Page 5 Wednesday, November 9, 2005 1:35 PM
1 Introduction 1
1.1 Introduction 1
1.2 History of C and C++ 2
1.3 C++ Standard Library 2
1.4 Key Software Trend: Object Technology 3
1.5 Typical C++ Development Environment 4
1.6 Notes About C++ and Small C++ How to Program, 5/e 7
1.7 Test-Driving a C++ Application 7
1.8 Introduction to Object Technology and the UML 12
1.9 Wrap-Up 17
1.10 Web Resources 17
2 Introduction to C++ Programming 21
2.1 Introduction 21
2.2 First Program in C++: Printing a Line of Text 21
2.3 Modifying Our First C++ Program 24
2.4 Another C++ Program: Adding Integers 25
2.5 Memory Concepts 28
2.6 Arithmetic 29
2.7 Decision Making: Equality and Relational Operators 33
2.8 Wrap-Up 36
3 Introduction to Classes and Objects 41
3.1 Introduction 41
3.2 Classes, Objects, Member Functions and Data Members 41
3.3 Overview of the Chapter Examples 42
3.4 Defining a Class with a Member Function 43
3.5 Defining a Member Function with a Parameter 45
3.6 Data Members, set Functions and get Functions 48
3.7 Initializing Objects with Constructors 54
3.8 Placing a Class in a Separate File for Reusability 57
3.9 Separating Interface from Implementation 60
3.10 Validating Data with set Functions 65
3.11 Wrap-Up 69
Contents
c++Book.book Page 1 Wednesday, November 9, 2005 1:35 PM
2 Contents
4 Control Statements: Part 1 73
4.1 Introduction 73
4.2 Algorithms 73
4.3 Pseudocode 73
4.4 Control Structures 74
4.5 if Selection Statement 78
4.6 if…else Double-Selection Statement 79
4.7 while Repetition Statement 83
4.8 Formulating Algorithms: Counter-Controlled Repetition 84
4.9 Formulating Algorithms: Sentinel-Controlled Repetition 89
4.10 Formulating Algorithms: Nested Control Statements 98
4.11 Assignment Operators 102
4.12 Increment and Decrement Operators 103
4.13 Wrap-Up 105
5 Control Statements: Part 2 111
5.1 Introduction 111
5.2 Essentials of Counter-Controlled Repetition 111
5.3 for Repetition Statement 113
5.4 Examples Using the for Statement 117
5.5 do…while Repetition Statement 120
5.6 switch Multiple-Selection Statement 122
5.7 break and continue Statements 130
5.8 Logical Operators 132
5.9 Confusing Equality (==) and Assignment (=) Operators 135
5.10 Structured Programming Summary 136
5.11 Wrap-Up 141
6 Functions and an Introduction to Recursion 145
6.1 Introduction 145
6.2 Program Components in C++ 145
6.3 Math Library Functions 147
6.4 Function Definitions with Multiple Parameters 148
6.5 Function Prototypes and Argument Coercion 152
6.6 C++ Standard Library Header Files 154
6.7 Case Study: Random Number Generation 155
6.8 Case Study: Game of Chance and Introducing enum 160
6.9 Storage Classes 163
6.10 Scope Rules 166
6.11 Function Call Stack and Activation Records 168
6.12 Functions with Empty Parameter Lists 172
6.13 Inline Functions 173
6.14 References and Reference Parameters 174
6.15 Default Arguments 178
6.16 Unary Scope Resolution Operator 180
c++Book.book Page 2 Wednesday, November 9, 2005 1:35 PM
Contents 3
6.17 Function Overloading 181
6.18 Function Templates 183
6.19 Recursion 185
6.20 Example Using Recursion: Fibonacci Series 188
6.21 Recursion vs. Iteration 191
6.22 Wrap-Up 193
7 Arrays and Vectors 203
7.1 Introduction 203
7.2 Arrays 203
7.3 Declaring Arrays 205
7.4 Examples Using Arrays 205
7.5 Passing Arrays to Functions 219
7.6 Case Study: Class GradeBook Using an Array to Store Grades 223
7.7 Searching Arrays with Linear Search 228
7.8 Sorting Arrays with Insertion Sort 230
7.9 Multidimensional Arrays 232
7.10 Case Study: Class GradeBook Using a Two-Dimensional Array 234
7.11 Introduction to C++ Standard Library Class Template vector 240
7.12 Wrap-Up 244
8 Pointers and Pointer-Based Strings 249
8.1 Introduction 249
8.2 Pointer Variable Declarations and Initialization 249
8.3 Pointer Operators 250
8.4 Passing Arguments to Functions by Reference with Pointers 253
8.5 Using const with Pointers 256
8.6 Selection Sort Using Pass-by-Reference 262
8.7 sizeof Operators 265
8.8 Pointer Expressions and Pointer Arithmetic 267
8.9 Relationship Between Pointers and Arrays 270
8.10 Arrays of Pointers 273
8.11 Case Study: Card Shuffling and Dealing Simulation 274
8.12 Function Pointers 279
8.13 Introduction to Pointer-Based String Processing 283
8.13.1 Fundamentals of Characters and Pointer-Based Strings 283
8.13.2 String Manipulation Functions of the String-Handling Library 285
8.14 Wrap-Up 292
9 Classes: A Deeper Look, Part 1 299
9.1 Introduction 299
9.2 Time Class Case Study 299
9.3 Class Scope and Accessing Class Members 305
9.4 Separating Interface from Implementation 307
c++Book.book Page 3 Wednesday, November 9, 2005 1:35 PM
4 Contents
9.5 Access Functions and Utility Functions 307
9.6 Time Class Case Study: Constructors with Default Arguments 310
9.7 Destructors 314
9.8 When Constructors and Destructors Are Called 315
9.9 Time Class Case Study:A Subtle Trap—Returning a Reference to a private
Data Member 318
9.10 Default Memberwise Assignment 320
9.11 Software Reusability 322
9.12 Wrap-Up 322
10 Classes: A Deeper Look, Part 2 327
10.1 Introduction 327
10.2 const (Constant) Objects and const Member Functions 327
10.3 Composition: Objects as Members of Classes 336
10.4 friend Functions and friend Classes 341
10.5 Using the this Pointer 345
10.6 Dynamic Memory Management with Operators new and delete 349
10.7 static Class Members 351
10.8 Data Abstraction and Information Hiding 356
10.8.1 Example: Array Abstract Data Type 357
10.8.2 Example: String Abstract Data Type 357
10.8.3 Example: Queue Abstract Data Type 357
10.9 Container Classes and Iterators 358
10.10 Proxy Classes 358
10.11 Wrap-Up 361
11 Operator Overloading; String and Array Objects 365
11.1 Introduction 365
11.2 Fundamentals of Operator Overloading 365
11.3 Restrictions on Operator Overloading 366
11.4 Operator Functions as Class Members vs. Global Functions 368
11.5 Overloading Stream Insertion and Stream Extraction Operators 369
11.6 Overloading Unary Operators 372
11.7 Overloading Binary Operators 372
11.8 Case Study: Array Class 373
11.9 Converting between Types 383
11.10 Case Study: String Class 384
11.11 Overloading ++ and -- 394
11.12 Case Study: A Date Class 395
11.13 Standard Library Class string 399
11.14 explicit Constructors 402
11.15 Wrap-Up 405
c++Book.book Page 4 Wednesday, November 9, 2005 1:35 PM
Contents 5
12 Object-Oriented Programming: Inheritance 409
12.1 Introduction 409
12.2 Base Classes and Derived Classes 410
12.3 protected Members 412
12.4 Relationship between Base Classes and Derived Classes 412
12.4.1 Creating and Using a CommissionEmployee Class 413
12.4.2 Creating a BasePlusCommissionEmployee Class Without Using Inheritance 417
12.4.3 Creating a CommissionEmployee–BasePlusCommissionEmployee Inheritance
Hierarchy 422
12.4.4 CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy
Using protected Data 426
12.4.5 CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy
Using private Data 435
12.5 Constructors and Destructors in Derived Classes 439
12.6 public, protected and private Inheritance 446
12.7 Software Engineering with Inheritance 446
12.8 Wrap-Up 448
13 Object-Oriented Programming: Polymorphism 451
13.1 Introduction 451
13.2 Polymorphism Examples 452
13.3 Relationships Among Objects in an Inheritance Hierarchy 453
13.3.1 Invoking Base-Class Functions from Derived-Class Objects 453
13.3.2 Aiming Derived-Class Pointers at Base-Class Objects 459
13.3.3 Derived-Class Member-Function Calls via Base-Class Pointers 460
13.3.4 Virtual Functions 462
13.3.5 Summary of the Allowed Assignments Between Base-Class and Derived-Class
Objects and Pointers 467
13.4 Type Fields and switch Statements 468
13.5 Abstract Classes and Pure virtual Functions 468
13.6 Case Study: Payroll System Using Polymorphism 470
13.6.1 Creating Abstract Base Class Employee 471
13.6.2 Creating Concrete Derived Class SalariedEmployee 474
13.6.3 Creating Concrete Derived Class HourlyEmployee 476
13.6.4 Creating Concrete Derived Class CommissionEmployee 478
13.6.5 Creating Indirect Concrete Derived Class BasePlusCommissionEmployee 480
13.6.6 Demonstrating Polymorphic Processing 481
13.7 (Optional) Polymorphism, Virtual Functions and Dynamic Binding “Under the Hood” 485
13.8 Case Study: Payroll System 488
13.9 Virtual Destructors 491
13.10 Wrap-Up 492
c++Book.book Page 5 Wednesday, November 9, 2005 1:35 PM
猜您喜欢