
最 低 价:¥71.28
定 价:¥99.00
作 者:(美)Stanley B.Lippman,Josée LaJoie,Barbara E.Moo 著
出 版 社:人民邮电出版社
出版时间:2006 年11月
I S B N:7115151695
| “在遇到无法解决的问题时,我总会求助于C++ Primer一书。” ——Bruce Eckel,“编程思想”系列图书作者 “众所周知, C++ Primer是学习C++最理想的参考书之一,适用于各种水平的C++程序员。第4版不但保持了这种传统,而且有了很大改善。” ——STEVE VINOSKI,IONA科技公司首席工程师,CORBA与C++权威 “(本书)不但使初学者迅速入门,而且是用优秀的编程实践引导他们入门。” ——NEVIN LIBER,资深工程师(自1988年起一直是C++开发者) C++诞生20年后,因其强大的功能、广泛的适用性和极高的效率,已经成为无庸置疑的主流编程语言。但是C++语言也不得不面对这样的挑战:其博大精深不仅令初学者望而生畏,而且即使是许多富于经验的老手也很难全面掌握,更有不少C++程序员一直背负着C语言的历史包袱,常常落入各种微妙难解的安全和性能陷阱。如何使现代C++理念深入人心,使C++更加容易学习和使用,已经成为众所瞩目的关键问题。 本书是久负盛名的C++经典教程,已经帮助全球无数程序员学会了C++。这一全新版本进行了彻底的修订,章节内容和编排都经过了重新组织,既显著改善了可读性,又充分体现了C++语言的最新进展和当前的业界最佳实践。 本书完美结合了C++大师Stanley B. Lippman丰富的实践经验和C++标准委员会原负责人Josée Lajoie对C++标准深入理解的完美结合。新版更加入了C++先驱Barbara E. Moo在C++教学方面的真知灼见。对C++基本概念和技术全面而且权威的阐述,对现代C++编程风格的强调,使本书不仅依然是初学者的最佳C++指南,而且也是高级程序不可或缺的参考书。 本书新版特色: 一开始就介绍C++标准库,使读者能够尽快编写实用程序,从而始终在实战环境中学习。 讲授现代编程风格和程序设计技术。 新增了大量教学辅助内容,用于强调重要的知识点、常见的错误、优秀的编程实践和使用提示。 大量来自实战的示例和习题,可以巩固所学技能。 书中例程的完整源代码可从www.turingbook.com网站下载。 |
| Stanley B.Lippman目前是微软公司Visual C++团队的架构师。他从1984年开始在贝尔实验室与C++的设计者Bjarne Stroustrup一起从事C++的设计与开发。又先后在迪士尼和梦工厂从事动画制作,还担任过JPL的高级顾问。他还著有Inside the C++ Object Model。. Josée Lajoie曾经是IMB加拿大研究中心C/C++编译器开发团队的成员,在ISO C++标准委员会工作了7年,担任过ISO核心语言工作组的主席和C++ Report杂志的专栏作家。.. Barbara E.Moo是拥有25年软件经验的独立咨询顾问。在AT&T.. << 查看详细 |
| contents . chapter 1 getting started 1 1.1 writing a simple c++program 2 1.1.1 compiling and executing our program 3 1.2 a first lookat input/output 5 1.2.1 standard input and output objects 6 1.2.2 a program that uses the io library 6 1.3 a word about comments 10 1.4 control structures 11 1.4.1 the while statement 12 1.4.2 the for statement 14 1.4.3 the if statement 17 1.4.4 reading an unknown number of inputs 18 1.5 introducing classes 20 1.5.1 the sales_item class 21 1.5.2 a first looka tmember functions 24 1.6 the c++program 25 chapter summary 28 defined terms 28 part i the basics 31 .chapter 2 variables and basic types 33 2.1 primitive built-in types 34 2.1.1 integral types 34 2.1.2 floating-point types 37 2.2 literal constants 37 2.3 variables 43 2.3.1 what is a variable? 45 2.3.2 the name of a variable 46 2.3.3 defining objects 48 2.3.4 variable initialization rules 50 2.3.5 declarations and definitions 52 2.3.6 scope of a name 54 2.3.7 define variables where they are used 55 2.4 const qualifier 56 2.5 references 58 2.6 typedef names 61 2.7 enumerations 62 2.8 class types 63 2.9 writing our own header files 67 2.9.1 designing our own headers 67 2.9.2 a brief introduction to the preprocessor 69 chapter summary 73 defined terms 73 chapter 3 library types 77 3.1 namespace using declarations 78 3.2 library stringtype 80 3.2.1 defining and initializing strings 80 3.2.2 reading and writing strings 81 3.2.3 operations on strings 83 3.2.4 dealing with the characters of a string 88 3.3 library vector type 90 3.3.1 defining and initializing vectors 91 3.3.2 operations on vectors 93 3.4 introducing iterators 95 3.4.1 iterator arithmetic 100 3.5 library bitset type 101 3.5.1 defining and initializing bitsets 102 3.5.2 operations on bitsets 104 chapter summary 107 defined terms 107 chapter 4 arrays and pointers 109 4.1 arrays 110 4.1.1 defining and initializing arrays 110 4.1.2 operations on arrays 113 4.2 introducing pointers 114 4.2.1 what is apointer? 115 4.2.2 defining and initializing pointers 116 4.2.3 operationson pointers 119 4.2.4 using pointers to access array elements 122 4.2.5 pointers and the const qualifier 126 4.3 c-style character strings 130 4.3.1 dynamically allocating arrays 134 4.3.2 interfacing to older code 139 4.4 multidimensioned arrays 141 4.4.1 pointers and multidimensioned arrays 143 chapter summary 145 defined terms 145 chapter 5 expressions 147 5.1 arithmetic operators 149 5.2 relational and logical operators 152 5.3 the bitwise operators 154 5.3.1 using bitset objectsor integral values 156 5.3.2 using the shift operators for io 158 5.4 assignment operators 159 5.4.1 assignment is right associative 160 5.4.2 assignment has low precedence 160 5.4.3 compound assignment operators 161 5.5 increment and decrement operators 162 5.6 the arrow operator 164 5.7 the conditional operator 165 5.8 the size of operator 167 5.9 comma operator 168 5.10 evaluating compound expressions 168 5.10.1 precedence 168 5.10.2 associativity 170 5.10.3 order of evaluation 172 5.11 the new and delete expressions 174 5.12 type conversions 178 5.12.1 when implicit type conversions occur 179 5.12.2 the arithmetic conversions 180 5.12.3 other implicit conversions 181 5.12.4 explicit conversions 183 5.12.5 when casts might be useful 184 5.12.6 named casts 184 5.12.7 old-stylecasts 186 chapter summary 188 defined terms 188 chapter 6 statements 191 6.1 simple statements 192 6.2 declaration statements 193 6.3 compound statements (blocks) 193 6.4 statement scope 194 6.5 the if statement 195 6.5.1 the if statement else branch 197 6.6 the switch statement 199 6.6.1 using a switch 200 6.6.2 control flow within a switch 201 6.6.3 the default label 203 6.6.4 switch expression and caselabels 203 6.6.5 variable definitions inside a switch 204 6.7 the while statement 204 6.8 the forloop statement 207 6.8.1 omitting parts of the for header 209 6.8.2 multiple definitions in the for header 210 6.9 the do while statement 210 6.10 the break statement 212 6.11 the continue statement 214 6.12 the goto statement 214 6.13 try blocks and exception handling 215 6.13.1 a throw expression 216 6.13.2 the try block 217 6.13.3 standard exceptions 219 6.14 using the preprocessor for debugging 220 chapter summary 223 defined terms 223 chapter 7 functions 225 7.1 defining a function 226 7.1.1 function return type 227 7.1.2 function parameter list 228 7.2 argument passing 229 7.2.1 nonreference parameters 230 7.2.2 reference parameters 232 7.2.3 vector and other container parameters 237 7.2.4 array parameters 238 7.2.5 managing arrays passed to functions 241 7.2.6 main:handling command-line options 243 7.2.7 function swith varying parameters 244 7.3 the return statement 245 7.3.1 function swith noreturn value 245 7.3.2 functions that returna value 246 7.3.3 recursion 249 7.4 function declarations 251 7.4.1 default arguments 253 7.5 local objects 254 7.5.1 automatic objects 255 7.5.2 static local objects 255 7.6 inline functions 256 7.7 class member functions 258 7.7.1 defining the body of a member function 259 7.7.2 defining a member function outside the class 261 7.7.3 writing the sales_item constructor 262 7.7.4 organizing class code files 264 7.8 overloaded functions 265 7.8.1 overloading and scope 268 7.8.2 function matching and argument conversions 269 7.8.3 the three steps in overload resolution 270 7.8.4 argument-type conversions 272 7.9 pointers to functions 276 chapter summary 280 defined terms 280 chapter 8 the io library 283 8.1 anobject-oriented library 284 8.2 condition states 287 8.3 managing the output buffer 290 8.4 file input and output 293 8.4.1 using file stream objects 293 8.4.2 file modes 296 8.4.3 a program to open and check input files 299 8.5 string streams 299 chapter summary 302 defined terms 302 part ii containers and algorithms 303 chapter 9 sequential containers 305 9.1 defininga sequential container 307 9.1.1 initializing container elements 307 9.1.2 constraints on types that a container can hold 309 9.2 iterators and iterator ranges 311 9.2.1 iterator ranges 314 9.2.2 some container operations invalidate iterators 315 9.3 sequence container operations 316 9.3.1 container typedefs 316 9.3.2 begin and end members 317 9.3.3 adding elements to a sequential container 318 9.3.4 relational operators 321 9.3.5 container size operations 323 9.3.6 accessing elements 324 9.3.7 erasing elements 326 9.3.8 assignment and swap 328 9.4 how a vector grows 330 9.4.1 capacity and reserve members 331 9.5 deciding which container to use 333 9.6 strings revisited 335 9.6.1 other ways to construct strings 338 9.6.2 other ways to change a string 339 9.6.3 string-only operations 341 9.6.4 string search operations 343 9.6.5 comparing strings 346 9.7 container adaptors 348 9.7.1 stack adaptor 350 9.7.2 queue and priority queue 351 chapter summary 353 defined terms 353 chapter 10 associative containers 355 10.1 preliminaries: the pair type 356 10.2 associative containers 358 10.3 the map type 360 10.3.1 defining a map 360 10.3.2 types defined by map 361 10.3.3 adding elements to a map 362 10.3.4 subscripting a map 362 10.3.5 using map::insert 364 10.3.6 finding and retrieving a map element 367 10.3.7 erasing elements from a map 368 10.3.8 iterating across a map 369 10.3.9 a word transformation map 369 10.4 the set type 372 10.4.1 defining and using sets 373 10.4.2 building a word-exclusion set 374 10.5 the multimap and multisettypes 375 10.5.1 addingand removing elements 376 10.5.2 finding elements in a multimap or multiset 376 10.6 using containers: text-query program 379 10.6.1 designof the query program 380 10.6.2 text query class 382 10.6.3 using the text query class 383 10.6.4 writing the member functions 385 chapter summary 388 defined terms 388 chapter 11 generic algorithms 391 11.1 overview 392 11.2 a first lookat the algorithms .. 395 11.2.1 read-only algorithms 396 11.2.2 algorithms that write container elements 398 11.2.3 algorithms that reorder container elements 400 11.3 revisiting iterators 405 11.3.1 insert iterators 406 11.3.2 iostream iterators 407 11.3.3 reverse iterators 412 11.3.4 const iterators 415 11.3.5 thefive iterator categories 416 11.4 structure of generic algorithms 419 11.4.1 algorithm parameter patterns 419 11.4.2 algorithm naming conventions 420 11.5 container-specific algorithms 421 chapter summary 424 defined terms 424 part iii classes and data abstraction 427 chapter 12 classes 429 12.1 class definitions and declarations 430 12.1.1 class definitions: a recap 430 12.1.2 data abstraction and encapsulation 432 12.1.3 more on class definitions 434 12.1.4 class declaration sversus definitions 437 12.1.5 class objects 439 12.2 the implicit this pointer 440 12.3 class scope 444 12.3.1 name look up in class scope 447 12.4 constructors 451 12.4.1 the constructor initializer 453 12.4.2 default arguments and constructors 458 12.4.3 the default constructor 458 12.4.4 implicitclass-type conversions 461 12.4.5 explicit initialization of class members 464 12.5 friends 465 12.6 static class members 467 12.6.1 static member functions 469 12.6.2 static data members 469 chapter summary 473 defined terms 473 chapter 13 copy control 475 13.1 the copy constructor 476 13.1.1 the synthesized copyconstructor 479 13.1.2 defining our own copy constructor 480 13.1.3 preventing copies 481 13.2 the assignment operator 482 13.3 the destructor 484 13.4 a message-handling example 486 13.5 managing pointer members 492 13.5.1 defining smart pointer classes 495 13.5.2 defining valuelike classes 499 chapter summary 502 defined terms 502 chapter 14 overloaded operations and conversions 505 14.1 defining an overloaded operator 506 14.1.1 overloaded operator design 510 14.2 input and output operators 513 14.2.1 overloading the output operator [[ 513 14.2.2 overloading the input operator ]] 515 14.3 arithmetic and relational operators 517 14.3.1 equality operators 518 14.3.2 relational operators 520 14.4 assignment operators 520 14.5 subscript operator 522 14.6 member access operators 523 14.7 increment and decrement operators 526 14.8 call operator and function objects 530 14.8.1 using function object swith library algorithms 531 14.8.2 library-defined function objects 533 14.8.3 function adaptors for function objects 535 14.9 conversions and class types 535 14.9.1 why conversions are useful 536 14.9.2 conversion operators 537 14.9.3 argument matching and conversions 541 14.9.4 overload resolution and class arguments 544 14.9.5 overloading,conversions, andoperators 547 chapter summary 552 defined terms 552 part iv object-oriented and generic programming 555 chapter 15 object-oriented programming 557 15.1 oop:anoverview 558 15.2 defining base and derived classes 560 15.2.1 defining a base class 560 15.2.2 protected members 562 15.2.3 derived classes 563 15.2.4 virtual and other member functions 566 15.2.5 public,private,and protected inheritance 570 15.2.6 friendship and inheritance 575 15.2.7 inheritance and static members 576 15.3 conversions and inheritance 577 15.3.1 derived-to-base conversions 577 15.3.2 conversions from base to derived 580 15.4 constructors and copy control 580 15.4.1 base-class constructors and copy control 580 15.4.2 derived-class constructors 581 15.4.3 copy control and inheritance 584 15.4.4 virtual destructors 587 15.4.5 virtuals in constructors and destructors 589 15.5 class scopeunder inheritance 590 15.5.1 name lookup happensat compile time 590 15.5.2 name collisions and inheritance 591 15.5.3 scopeand member functions 592 15.5.4 virtual functions and scope 594 15.6 pure virtual functions 595 15.7 containers and inheritance 597 15.8 handle classes and inheritance 598 15.8.1 a pointerlike handle 599 15.8.2 cloning an unknown type 602 15.8.3 using the handle 603 15.9 text queries revisited 607 15.9.1 an object-oriented solution 609 15.9.2 a valuelike handle 610 15.9.3 the query_baseclass 612 15.9.4 the query handle class 613 15.9.5 the derived classes 616 15.9.6 the eval functions 618 chapter summary 621 defined terms 621 chapter 16 templates and generic programming 623 16.1 template definitions 624 16.1.1 defining a function template 625 16.1.2 defining a class template 627 16.1.3 template parameters 628 16.1.4 template type parameters 630 16.1.5 non type template parameters 632 16.1.6 writing generic programs 633 16.2 instantiation 636 16.2.1 template argument deduction 637 16.2.2 function-template explicit arguments 642 16.3 template compilation models 643 16.4 class template members 647 16.4.1 class-template member functions 651 16.4.2 template arguments for nontype parameters 655 16.4.3 friend declarations in class templates 655 16.4.4 queue and queue item friend declarations 658 16.4.5 member templates 660 16.4.6 the complete queue class 664 16.4.7 static members of class templates 665 16.5 ageneric handleclass 666 16.5.1 defining the handle class 667 16.5.2 using the handle 668 16.6 template specializations 671 16.6.1 specializing a function template 672 16.6.2 specializing a class template 675 16.6.3 specializing members but not the class 677 16.6.4 class-template partial specializations 678 16.7 overloading and function templates 679 chapter summary 683 defined terms 683 part v advanced topics 685 chapter 17 tools for large programs 687 17.1 exception handling 688 17.1.1 throwing an exception of class type 689 17.1.2 stack unwinding 691 17.1.3 catching an exception 693 17.1.4 rethrow 695 17.1.5 the catch-all handler 696 17.1.6 function try blocks and constructors 696 17.1.7 exception class hierarchies 697 17.1.8 automatic resource deallocation 700 17.1.9 the auto_ptrclass 702 17.1.10exception specifications 706 17.1.11function pointer exception specifications 711 17.2 namespaces 712 17.2.1 namespace definitions 712 17.2.2 nested namespaces 717 17.2.3 unnamed namespaces 718 17.2.4 using namespace members 720 17.2.5 classes,namespaces,and scope 724 17.2.6 overloading and namespaces 727 17.2.7 namespaces and templates 730 17.3 multiple and virtual inheritance 731 17.3.1 multiple inheritance 731 17.3.2 conversions and multiple base classes 734 17.3.3 copycontrol for multiply derived classes 737 17.3.4 class scopeunder multiple inheritance 737 17.3.5 virtual inheritance 740 17.3.6 virtual base class declaration 742 17.3.7 special initialization semantics 744 chapter summary 748 defined terms 748 chapter 18 specialized tools and techniques 753 18.1 optimizing memory allocation 754 18.1.1 memory allocation in c++ 754 18.1.2 the allocatorclass 755 18.1.3 operator new and operator delete functions 759 18.1.4 placement new expressions 761 18.1.5 explicit destructor invocation 762 18.1.6 class specific new and delete 763 18.1.7 a memory-allocator base class 766 18.2 run-time type identification 772 18.2.1 the dynamic_cast operator 773 18.2.2 the typeid operator 775 18.2.3 using rtti 777 18.2.4 the type_info class 779 18.3 pointer to class member 780 18.3.1 declaring a pointer to member 781 18.3.2 using a pointer to class member 783 18.4 nested classes 786 18.4.1 a nested-class implementation 787 18.4.2 name lookup in nested class scope 791 18.5 union: aspace-saving class 792 18.6 local classes 796 18.7 inherently nonportable features 797 18.7.1 bit-fields 798 18.7.2 volatile qualifier 799 18.7.3 linkage directives: extern "c" 801 chapter summary 805 defined terms 805 appendix a the library 809 a.1 librarynames and headers 810 a.2 a brief tour of the algorithms 811 a.2.1 algorithms to findan object 811 a.2.2 otherread-only algorithms 813 a.2.3 binary-search algorithms 814 a.2.4 algorithms that write container elements 815 a.2.5 partitioning and sorting algorithms 817 a.2.6 general reordering operations 818 a.2.7 permutation algorithms 820 a.2.8 set algorithms for sorted sequences 821 a.2.9 minimum and maximum values 822 a.2.10 numeric algorithms 823 a.3 the io library revisited 825 a.3.1 format state 825 a.3.2 many manipulators change the format state 825 a.3.3 controlling output formats 826 a.3.4 controlling input formatting 833 a.3.5 unformatted input/output operations 834 a.3.6 single-byte operations 834 a.3.7 multi-byte operations 835 a.3.8 random access to a stream 837 a.3.9 reading and writing to the same file 840 index ...843 |
商品评论(0条)