C++编程思想 英文本PDF电子书下载
- 电子书积分:22 积分如何计算积分?
- 作 者:(美)Bruce Eckel著
- 出 版 社:北京:机械工业出版社
- 出版年份:2002
- ISBN:7111091620
- 页数:801 页
Preface 1
What s inside… 1
What s new in the second edition 2
What s in Volume 2 of this book 3
How to get Volume 2 3
Prerequisites 3
Learning C++ 4
Goals 5
Chapters 7
Exercise solutions 12
Source code 12
Exercises 12
Language standards 14
Language support 15
The book s CD ROM 15
CD ROMs ,seminars,and consulting 16
Errors 16
About the cover 17
Book design and production 18
Acknowledgements. 19
1:Introduction to Objects 21
The progress of abstraction 22
An object has an interface 25
The hidden implementation 28
Reusing the implementation 29
Inheritance:reusing the interface 31
Is-a vs.is-like-a relationships 35
Interchangeable objects with polymorphism 37
Creating and destroying objects 41
Exception handling:dealing with errors 43
Analysis and design 44
Phase 0:Make a plan 47
Phase 1: What are we making? 48
Phase 2:How will we build it? 52
Phase 3: Build the core 56
Phase 4:Iterate the use cases 57
Phase 5:Evolution 58
Plans pay off 60
Extreme programming 61
Write tests first 61
Pair programming 63
Why C++ succeeds 64
A better C 65
You re already on the learning curve 65
Efficiency 66
Systems are easier to express and understand 66
Maximal leverage with libraries 67
Source-code reuse with templates 67
Error handling 67
Strategies for transition 68
Programming in the large 68
Guidelines 69
Management obstacles 71
Summary 73
2:Making &Using Objects 75
The process of language translation 76
Interpreters 77
Compilers 77
The compilation process 79
Tools for separate compilation 80
Declarations vs.definitions 81
Linking 87
Using libraries 88
Your first C++ program 90
Using the iostreams class 90
Namespaces 91
Fundamentals of program structure 93
Hello,world! 94
Running the compiler 95
More about iostreams 96
Character array concatenation 96
Reading input 97
Calling other programs 98
Introducing strings 98
Reading and writing files 100
Introducing vetor 102
Summary 108
Exercises 109
3:The C in C++ 111
Creating functions 112
Function return values 115
Using the C function library 116
Creating your own libraries with the librarian 117
Controlling execution 117
True and false 117
If-else 118
While 119
Do-while 120
for 121
The break and continue keywords 122
Switch 123
Using and misusing goto 125
Recursion 126
Introduction to operators 127
Precedence 127
Auto increment and decrement 128
Introduction to data types 129
Basic built-in types 129
bool,true,&false 131
Specifiers 132
Introduction to pointers 133
Modifying the outside object 137
Introduction to C++ references 140
Pointers and references as modifiers 141
Scoping 143
Defining variables on the fly 145
Specifying storage allocation 147
Global variables 147
Local variables 149
static 149
extern 151
Constants 153
volatile 155
Mathematical operators 156
Operators and their use 156
Assignment 156
Relational operators 158
Logical operators 158
Bitwise operators 159
Shift operators 160
Unary operators 163
The ternary operator 164
The comma operator 165
Common pitfalls when using operators 166
Casting operators 166
C++ explicit casts 167
sizeof-an operator by itself 172
Explicit operators 173
The asm keyword 173
Composite type creation 174
Aliasing names with typedef 174
Combining variables with struct 175
Clarifying programs with enum 179
Saving memory with union 181
Arrays 182
Debugging hints 193
Debugging flags 194
Turning variables and expressions into strings 196
The C assert() macro 197
Defining a function pointer 198
Function addresses 198
Complicated declarations &definitions 199
Using a function pointer 200
Arrays of pointers to functions 201
Make:managing separate compilation 202
Make activities 204
Makefiles in this book 207
An example makefile 208
Summary 210
Exercises 210
4: Data Abstraction 217
A tiny C-like library 219
Dynamic storage allocation 223
Bad guesses 227
What s wrong? 229
The basic object 230
What s an object? 238
Abstract data typing 239
Object detalls 240
Header file etiquette 241
Importance of header files 242
The muitiple-declaration problem 244
The preprocessor directives #define,#ifdef,and #endif 245
A standard for header files 246
Namespaces in headers 247
Using headers in projects 248
Nested structures 248
Global scope resolution 253
Summary 253
Exercises 254
5:Hiding the Implementation 259
Setting limits 260
C++ access control 261
protected 263
Friends 263
Nested friends 266
Object layout 269
Is it pure? 269
The class 270
Modifying Stash to use access control 273
Modifying Stack to use access control 274
Handle classes 275
Hiding the implementation 276
Reducing recompilation 276
Summary 279
Exarcises 280
6: Initialization&Cleanup 283
Guaranteed initialization with the constructor 285
Guaranteed cleanup with the destructor 287
Elimination of the definition block 289
for loops 291
Storage allocation 292
Stash with constructors and destructors 294
Stack with constructors&destructors 298
Aggregate inltialization 301
Default constructors 304
Summary 305
Exercises 306
7:Function Overloading &Default Arguments 309
More name decoration 311
Overloading on return values 312
Type-safe linkage 313
Overloading example 314
unions 318
Default arguments 321
Placeholder arguments 323
Choosing overloading vs.default arguments 324
Summary 329
Exercises 330
8:Constants 333
Value substitution. 334
Const in header files 335
Satety consts 336
Aggregates 337
Differences with C 338
Pointer to const 340
Pointers 340
const pointer 341
Assignment and type checking 343
Function arguments &return values 344
Passing by const value 344
Returning by const value 345
Passing and returning addresses 349
Classes 352
const in classes 353
Compile-time constants in classes 356
const objects&member functions 359
volatile 365
Exercises 367
Summary 367
9:Inline Functions 371
Preprocessor pitfalls 372
Macros and access 376
Inline functions 377
Inlines inside classes 378
Access functions 379
Stash &Stack with inlines 385
Inlines&the compiler 390
Limitations 390
Forward references 391
Hidden activities in constructors&destructors 392
Reducing clutter 393
More preprocessor features 395
Token pasting 396
Improved error checking 396
Summary 400
Exercises 400
10:Name Control 405
Static elements from C 406
static variables inside functions 406
Controlling linkage 412
Other storage class specifiers 414
Namespaces 414
Creating a namespace 415
Using a namespace 417
The use of namespaces 422
Static members in C++ 423
Defining storage for static data members 424
Nested and local classes 428
static member functions 429
Static initialization dependency 432
What to do 434
Alternate linkage specifications 442
Summary 443
Exercises 443
11:References &the Copy-Constructor 449
Pointers in C++ 450
References in C++ 451
References in functions 452
Argument-passing guidelines 455
The Copy-constructor 455
Passing &returning by value 455
Copy-construction 462
Default copy-constructor 468
Alternatives to copy-construction 471
Pointers to members 473
Functions 475
Summary 478
Exercises 479
12:Operator Overloading 485
Warning&reassurance 486
Syntax 487
Overloadable operators 488
Unary operators 489
Binary operators 493
Arguments&return values 505
Unusual operators 508
Operators you can t overload 517
Non-member operators 518
Basic guidelines 520
Overloading assignment 521
Behavior of operator= 522
Automatic type conversion 533
Constructor conversion 534
Operator conversion 535
Type conversion example 538
Pitfalls in automatic type conversion 539
Summary 542
Exercises 542
13:Dynamic Object Creation 547
Object creation 549
C s approach to the heap 550
Operator new 552
Operator delete 553
A simple example 553
Memory manager overhead 554
Early examples redesigned 555
delete void*is probably a bug 555
Cleanup responsibility with pointers 557
Stash for pointers 558
new&delete for arrays 563
Making a pointer more like an array 564
Running out of storage 565
Overloading new &delete 566
Overloading global new &delete 568
Overloading new &delete for a class 570
Overloading new &delete for arrays 573
Constructor calls 576
placement new &delete 577
Summary 580
Exercises 580
14:Inheritance &Composition 583
Composition syntax 584
Inheritance syntax 586
The constructor initializer list 588
Member object initialization 589
Built-in types in the initializer list 589
Combining composition &inheritance 591
Order of constructor &destructor calls 592
Name hiding 595
Functions that don t automatically inherit 600
Inheritance and static member functions 604
Choosing composition vs.inheritance 604
Subtyping 606
private inheritance 609
protected 610
protected inheritance 611
Operator overloading &inheritance 612
Multiple inheritance 613
Incremental development 614
Upcasting 615
Why“upcasting?” 617
Upcasting and the copy-constructor 617
Composition vs.inheritance(revisited) 620
Pointer&reference upcasting 622
A crisis 622
Summary 623
Exercises 623
15:Polymorphism&Virtual Functions 627
Evolution of C++ programmers 628
Upcasting 629
The problem 631
Function call binding 631
Virtual functions 632
Extensibillity 633
How C++ implernents late binding 636
Storing type information 637
Picturing virtual functions 639
Under the hood 642
Installing the vpointer 643
Objects are different 644
Why virtual functions? 645
Abstract base classes and pure virtual functions 646
Pure virtual definitions 651
Inheritance and the VTABLE 652
Object slicing 655
Overloading &overriding 658
Variant return type 660
virtual functions&constructors 662
Order of constructor calls 663
Behavior of virtual functions inside constructors 664
Destructors and virtual destructors. 665
Pure virtual destructors 668
Virtuals in destructors 670
Creating an object-based hierarchy 671
Operator overloading 675
Downcasting 678
Summary 681
Exercises 682
16:Introduction to Templates 689
Containers 690
The need for containers 692
Overview of templates 693
The template solution 696
Template syntax 697
Non-inline function definitions 699
IntStack as a template 701
Constants in templates 703
Stack and Stash as templates 705
Templatized pointer Stash 707
Turning ownership on and off 713
Holding objects by value 716
Introducing iterators 719
Stack with iterators 728
PStash with iterators 732
Why iterators? 738
Function templates 742
Summary 743
Exercises 744
A:Coding Style 747
B: Programming Guidelines 759
C:Recommended Reading 775
C 776
General C++ 776
My own list of books 777
Depth &dark corners 778
Analysis &design 779
Index 783
- 《程序逻辑及C语言编程》卢卫中,杨丽芳主编 2019
- 《先秦政治思想史》梁启超著 2019
- 《《鬼谷子》思想新解 上》林仁政著 2015
- 《刘泽华全集 先秦政治思想史 下》刘泽华著;南开大学历史学院编 2019
- 《龙影 西方世界中国观念的思想渊源 增补版》何辉著 2019
- 《批判 建构与实践 戴维·佩珀生态社会主义思想研究》梅丽著 2019
- 《中国共产党思想通史 第2卷》李曙新 2014
- 《全国职业院校工业机器人技术专业规划教材 工业机器人现场编程》(中国)项万明 2019
- 《中国共产党思想通史 第7卷》张静如总主编 2014
- 《澳大利亚汉学家李瑞智之研究 中华传统思想文化的当代价值》李书仓 2018
- 《指向核心素养 北京十一学校名师教学设计 英语 七年级 上 配人教版》周志英总主编 2019
- 《北京生态环境保护》《北京环境保护丛书》编委会编著 2018
- 《高等教育双机械基础课程系列教材 高等学校教材 机械设计课程设计手册 第5版》吴宗泽,罗圣国,高志,李威 2018
- 《指向核心素养 北京十一学校名师教学设计 英语 九年级 上 配人教版》周志英总主编 2019
- 《高等院校旅游专业系列教材 旅游企业岗位培训系列教材 新编北京导游英语》杨昆,鄢莉,谭明华 2019
- 《中国十大出版家》王震,贺越明著 1991
- 《近代民营出版机构的英语函授教育 以“商务、中华、开明”函授学校为个案 1915年-1946年版》丁伟 2017
- 《新工业时代 世界级工业家张毓强和他的“新石头记”》秦朔 2019
- 《智能制造高技能人才培养规划丛书 ABB工业机器人虚拟仿真教程》(中国)工控帮教研组 2019
- 《AutoCAD机械设计实例精解 2019中文版》北京兆迪科技有限公司编著 2019