标准C++与面向对象程序设计:英文版

标准C++与面向对象程序设计:英文版
作 者: Paul Wang
出版社: 机械工业出版社
丛编项: 经典原版书库
版权说明: 本书为公共版权或经版权方授权,请支持正版图书
标 签: C
ISBN 出版时间 包装 开本 页数 字数
未知 暂无 暂无 未知 0 暂无

作者简介

  PaulW.Wang:于麻省理工学院(MIT)获得博士学位,现任肯特州立大学计算机科学系教授和计算数学研究所主任。他是国际著名的计算机科学家和资深顾问,发表过100多篇研究论文,并著有多本倍受赞誉的计算机科学书籍。

内容简介

教授C++和OOP方法的一本优秀教材 标准C++是最流行的面向对象程序设计(OOP)语言之一。本书将OOP的概念和方法融合在C++中,更重要的 是说明如何将C++的各项功能综合运用,以达到OOP的目的。书中全面介绍了面向对象程序设计的重要概念,如数据抽象、封装、信息隐藏、继承和多态性等,同时还包含了C++语言的OOP方面的所有内容,包括类、操作符重载继承、模板等。此外,书中还描述了新的ANSIC++标准、模板库等。通过阅读本书,读者将对C++语言及面向对象程序设计有一个全面、深刻的了解。 本书特点: ·为了使读者很快地掌握C++语言,本书前面的几章介绍了C++的基础知识,并且讨论了C++语言的一些基本特征·为了加速读者学习本书的过程,书中还提供了许多编程技巧和推荐的编程风格等·为了使本书易于在教学中使用,作者开发了许多有趣的例子和具有挑战性的习题·书中的概念和编程结构都有足够的示例说明,按章组织的示例程序包大约有400个文件,包含了完整的源代码: 用于UNIX和PC的完整示例程序包可以在WWW.brookscole.com站点获得本书内容的组织和介绍均以简单。明确、易学为出发点,适合作为本科生程序设计课程的教材。

图书目录

Introduction 1

ONE C++ Primer Part 1: Basics 8

1.1 Object-Oriented Program Structure 8

1.2 Functions 9

1.3 Running the First Example 12

1.4 Statements 12

1.5 The while Statement 13

1.6 Simple Conditional Statements 16

1.7 Characters and Character Input and Output 17

1.8 More Basic Constructs 20

1.9 Data Types and Declarations 26

1.10 Operators and Expressions 29

1.11 Enumerations 35

1.12 Arrays 37

1.13 Pointers 40

1.14 An Example 41

1.15 Iteration Control 42

1.16 Choices by switch 46

1.17 Summary 48

Exercises 48

TWO C++ Primer Part II: Object-Based Programming 51

2.1 Data Abstraction and Encapsulation 51

2.2 Function Calls and Argument Passing 58

2.3 Command-Line Arguments 61

2.4 Environment Variables 62

2.5 The string Class 63

2.6 Problem Solving with Objects 65

2.7 C++ I/O Streams 70

2.8 Error Handling 70

2.9 Object-Based Thinking 73

2.10 C++ Programming Tips 74

2.11 Summary 77

Exercises 78

THREE Key Constructs 80

3.1 Identifier Scoping 81

3.2 Namespaces 84

3.3 More on Declarations 86

3.4 Recursion 89

3.5 A Class of Fractions 93

3.6 Optional and Variable-Length Arguments 97

3.7 Overloading Functions 99

3.8 References 102

3.9 Read-Only Variables and Parameters 103

3.10 The typedef Declaration 105

3.11 Storage Allocation and Management 106

3.12 A Circular Buffer 109

3.13 Implicit Type Conversions 114

3.14 Explicit Type Cast 116

3.15 HOW to Use Header Files 117

3.16 Summary 119

Exercises 120

FOUR Arrays, Pointers, and Generic Code 123

4.1 Array Concepts and Declarations 123

4.2 Pointers and Address Arithmetic 125

4.3 TWo-Dimensional Arrays 133

4.4 A Matrix Class 135

4.5 A Class of Polynomials 138

4.6 Array Objects: vector 141

4.7 Sorting Text Lines with Objects 143

4.8 Pointers and Function Calls 151

4.9 Arrays, Pointers, and References 154

4.10 Multiple Indirection 154

4.11 Generic Programs 156

4.12 A Generic Sorting Program 162

4.13 Pointers and Dynamically Allocated Storage 165

4.14 Summary 168

Exercises 169

FIVE Classes and Objects 172

5.1 Defining Classes 172

5.2 Creating and Initializing Objects 175

5.3 The Host Object 181

5.4 Internal-External Decoupling 182

5.5 Pocket Calculator Simulation 183

5.6 Built-in Operations for Objects 192

5.7 Object Destruction 193

5.8 Friends of a Class 195

5.9 Recursive Structures 197

5.10 Instance and Static Members 204

5.11 The Size of Objects 210

5.12 Generic Lists 211

5.13 Unions and Bit Fields 216

5.14 Summary 216

Exercises 217

six I/O Streams and the Standard Library 219

6.1 Different Header Files 219

6.2 C-Style String Input and Output 220

6.3 String Objects 222

6.4 A String Tokenizer 225

6.5 Operations on Characters 228

6.6 Numeric Computations 229

6.7 The I/O Stream Library 230

6.8 Stream I/O for Objects 240

6.9 I/O Manipulators 242

6.10 Summary 244

Exercises 245

SEVEN Inheritance and Class Derivation 248

7.1 Class Derivation 249

7.2 Derived Classes and Objects 252

7.3 Public Derivation 255

7.4 Derivation Principles 258

7.5 Access Control Under Class Derivation 259

7.6 Private Derivation 261

7.7 Specialization of Generic Classes 263

7.8 Type Relations Under Inheritance 265

7.9 Assignment of Objects 267

7.10 Copying of Objects 271

7.11 Derived-Object Assignment and Copying 274

7.12 Object Assignmentand Copying via Derivation 276

7.13 Multiple Inheritance 278

7.14 The I/O Stream Class Hierarchy 282

7.15 Summary 283

Exercises 284

EIGHT operator Overloading, Iterators, and

Exceptions 287

8.1 Operator Overloading 287

8.2 A Reference-Count String Class 290

8.3 Overloading [] 293

8.4 Overloading ++ and -- 294

8.5 Smart Pointers 295

8.6 Iterators 296

8.7 Nested and Local Classes 299

8.8 Robust Classes 302

8.9 User-Defined Type Conversions 303

8.10 Error and Exception Handling 306

8.11 Matrix with Exceptions 314

8.12 Managing Free Storage 316

8.13 Summary 319

Exercises 320

NINE OOP Techniques 322

9.1 Programming with Plug-Compatible Objects 322

9.2 Run-Time Type Identification 330

9.3 A Generic Tree 335

9.4 Planning Uniform Public Interfaces 343

9.5 Destruction of Plug-Compatible Objects 352

9.6 Ordering Text Lines 354

9.7 Interfaces 357

9.8 Understanding Virtual Functions 359

9.9 Inheritance Planning 361

9.10 Object-Family Classes 363

9.11 Summary 371

Exercises 372

TEN Templates 375

10.1 Basic Concepts 375

10.2 Function Templates 377

10.3 Class Templates 383

10.4 Template Compilation 388

10.5 A List Template 390

10.6 Class Template Specialization 397

10.7 Derived-Class Template 397

10.8 A Generic Hash Table 400

10.9 Generic Programming Approaches 407

10.10 Summary 409

Exercises 409

ELEVEN Standard Containers 413

11.1 The STL 413

11.2 Standard Container Headers 414

11.3 Efficiency of Sequence Containers 416

11.4 Using stack 417

11.5 Associative Containers 418

11.6 Standard Container Iterators and typedefs 421

11.7 Generic Algorithms for Containers 426

11.8 Ordered Sets 429

11.9 Standard Functors 431

11.10 For More STL Information 434

11.11 Pointers to Members 434

11.12 Instance Functions as Functors 439

11.13 Summary 439

Exercises 440

TWELVE Web CGI Programming 442

12.1 About Networking 442

12.2 Internet Basics A n.A.

12.3 The World-Wide Web 446

12.4 What IS HTML? 448

12.5 Dynamic Generation of Web Pages 450

12.6 HTML Produced from C++ 452

12.7 Forms in HTML 455

12.8 HTTP Message Formats 456

12.9 Writing CGI Programs 458

12.10 Receiving Form Data 459

12.11 User Feedback Handling 461

12.12 More Information 464

12.13 Summary 465

Exercises 465

THIRTEEN Object-Oriented Design 467

13.1 Decomposition Approaches 468

13.2 Object-Oriented Design Principles 469

13.3 Design Patterns 472

13.4 The CRC Method 474

13.5 Interfacing to Existing Systems 475

13.6 Pocket Calculator Simulation 479

13.7 Summary 488

Exercises 488

FOURTEEN Compiling and Preprocessing 490

14.1 Compiling and Running C++ Programs 490

14.2 Preprocessing 492

14.3 Header Files 493

14.4 Symbolic Constants and Macros 494

14.5 Inline Functions Versus Macros 496

14.6 Conditional Text Inclusion 497

14.7 Once-Only Header Files 500

14.8 Standard Macros 500

14.9 Compilation and Execution 502

14.10 Summary 506

Exercises 507

APPENDICES

A Summary of C++ Constructs 509

B Summary of Special Member Functions 515

C C-Style Strings 516

D Unions and Bit Fields 519

E Interactive Debugging with dbx 525

F Functions with a Variable Number of Arguments 528

G Operator Precedence 531

H Implicit Type Conversions 532

I C++ Library Functions Common with C 534

J C-Style Input/output 542

K Interfacing C++ and C Programs 547

L Header Files 551

Index 552