
| 通过完整,权威性的DEITEL活代码介绍C++、面向对象编程(OOP)和使用UML2的面向对象设计(OOD)。 C++是极受大家欢迎的面向对象程序设计语言之一。 这一全球广泛采用的C++教材的新版本介绍了如何使用Ogre库进行游戏编程。 |
| Paul J. Deitel是Deitel & Associates公司的CEO和首席技术主管,毕业于麻省理工学院的斯隆工商管理学院,主修信息技术。Paul拥有Java程序员资格和Java开发者资格认证,他被Sun Microsystems授予“Java冠军(Java Champion)”。在Deitel & Associates公司,他负责向业内客户讲授Java、C、C++、C#和Visual Basic等课程。客户主要包括IBM公司、Sun Microsystems公司、戴尔公司、朗讯科技公司、高保真公司(Fidelity)、位于肯尼迪太空中心的NASA、美国国家强风暴实验室(the National Severe Storm Labo.. << 查看详细 |
| contents chapter 1 introduction to computers, the internet and the world wide web 1 1.1 introduction 2 1.2 what is a computer? 3 1.3 computer organization 3 1.4 early operating systems 4 1.5 personal, distributed and client/server computing 4 1.6 the internet and the world wide web 5 1.7 web 2.0 5 1.8 machine languages, assembly languages and high-level languages 6 1.9 history of c and c++ 7 1.10 c++ standard library 8 1.11 history of java 9 1.12 fortran, cobol, pascal and ada 9 1.13 basic, visual basic, visual c++, c# and .net 9 1.14 key software trend: object technology 10 1.15 typical c++ development environment 11 1.16 notes about c++ and c++ how to program, 6/e 13 1.17 test-driving a c++ application 13 1.18 software technologies 17 .1.19 game programming with the ogre libraries 18 1.20 future of c++: open source boost libraries, tr1 and c++0x 18 1.21 software engineering case study:introduction to object technology and the uml 19 1.22 web resources 23 chapter 2 introduction to c++ programming 34 2.1 introduction 34 2.2 first program in c++: printing a line of text 35 2.3 modifying our first c++ program 37 2.4 another c++ program: adding integers 38 2.5 memory concepts 41 2.6 arithmetic 42 2.7 decision making: equality and relational operators 45 2.8 (optional) software engineering case study: examining the atm requirements specification 48 chapter 3 introduction to classes and objects 64 3.1 introduction 64 3.2 classes, objects, member functions and data members 65 3.3 overview of the chapter examples 66 3.4 defining a class with a member function 66 3.5 defining a member function with a parameter 69 3.6 data members, set functions and get functions 71 3.7 initializing objects with constructors 76 3.8 placing a class in a separate file for reusability 79 3.9 separating interface from implementation 82 3.10 validating data with set functions 86 3.11 (optional) software engineering case study: identifying the classes in the atm requirements specification 89 chapter 4 control statements: part 1 101 4.1 introduction 101 4.2 algorithms 102 4.3 pseudocode 102 4.4 control structures 103 4.5 if selection statement 106 4.6 if...else double-selection statement 107 4.7 while repetition statement 111 4.8 formulating algorithms: counter-controlled repetition 112 4.9 formulating algorithms: sentinel-controlled repetition 116 4.10 formulating algorithms: nested control statements 123 4.11 assignment operators 127 4.12 increment and decrement operators 127 4.13 (optional) software engineering case study: identifying class attributes in the atm system 130 chapter 5 control statements: part 2 147 5.1 introduction 147 5.2 essentials of counter-controlled repetition 148 5.3 for repetition statement 149 5.4 examples using the for statement 152 5.5 do...while repetition statement 156 5.6 switch multiple-selection statement 157 5.7 break and continue statements 164 5.8 logical operators 166 5.9 confusing the equality (==) and assignment (=) operators 169 5.10 structured programming summary 170 5.11 (optional) software engineering case study: identifying objects?states and activities in the atm system 173 chapter 6 functions and an introduction to recursion 186 6.1 introduction 187 6.2 program components in c++ 187 6.3 math library functions 188 6.4 function definitions with multiple parameters 189 6.5 function prototypes and argument coercion 193 6.6 c++ standard library header files 195 6.7 case study: random number generation 196 6.8 case study: game of chance; introducing enum 200 6.9 storage classes 203 6.10 scope rules 205 6.11 function call stack and activation records 208 6.12 functions with empty parameter lists 209 6.13 inline functions 211 6.14 references and reference parameters 212 6.15 default arguments 216 6.16 unary scope resolution operator 217 6.17 function overloading 218 6.18 function templates 220 6.19 recursion 222 6.20 example using recursion: fibonacci series 224 6.21 recursion vs. iteration 226 6.22 (optional) software engineering case study: identifying class operations in the atm system 229 chapter 7 arrays and vectors 252 7.1 introduction 253 7.2 arrays 253 7.3 declaring arrays 254 7.4 examples using arrays 255 7.4.1 declaring an array and using a loop to initialize the array’s elements 255 7.4.2 initializing an array in a declaration with an initializer list 255 7.4.3 specifying an array’s size with a constant variable and setting array elements with calculations 256 7.4.4 summing the elements of an array 258 7.4.5 using bar charts to display array data graphically 259 7.4.6 using the elements of an array as counters 260 7.4.7 using arrays to summarize survey results 261 7.4.9 static local arrays and automatic local arrays 265 7.5 passing arrays to functions 266 7.6 case study: class gradebook using an array to store grades 270 7.7 searching arrays with linear search 274 7.8 sorting arrays with insertion sort 276 7.9 multidimensional arrays 277 7.10 case study: class gradebook using a two-dimensional array 280 7.11 introduction to c++ standard library class template vector 285 7.12 (optional) software engineering case study: collaboration among objects in the atm system 288 chapter 8 pointers and pointer-based strings 308 8.1 introduction 309 8.2 pointer variable declarations and initialization 309 8.3 pointer operators 310 8.4 passing arguments to functions by reference with pointers 312 8.5 using const with pointers 315 8.6 selection sort using pass-by-reference 320 8.7 sizeof operator 322 8.8 pointer expressions and pointer arithmetic 324 8.9 relationship between pointers and arrays 326 8.10 arrays of pointers 329 8.11 case study: card shuffling and dealing simulation 330 8.12 function pointers 334 8.13 introduction to pointer-based string processing 338 8.13.1 fundamentals of characters and pointer-based strings 339 8.13.2 string-manipulation functions of the string-handling library 340 chapter 9 classes: a deeper look, part 1 368 9.1 introduction 368 9.2 time class case study 369 9.3 class scope and accessing class members 373 9.4 separating interface from implementation 374 9.5 access functions and utility functions 376 9.6 time class case study: constructors with default arguments 378 9.7 destructors 382 9.8 when constructors and destructors are called 382 9.9 time class case study: a subtle trap裄eturning a reference to a private data member 385 9.10 default memberwise assignment 387 9.11 (optional) software engineering case study: starting to program the classes of the atm system 388 chapter 10 classes: a deeper look, part 2 399 10.1 introduction 399 10.2 const (constant) objects and const member functions 400 10.3 composition: objects as members of classes 407 10.4 friend functions and friend classes 412 10.5 using the this pointer 414 10.6 dynamic memory management with operators new and delete 418 10.7 static class members 420 10.8 data abstraction and information hiding 424 10.8.1 example: array abstract data type 425 10.8.2 example: string abstract data type 425 10.8.3 example: queue abstract data type 426 10.9 container classes and iterators 426 10.10 proxy classes 426 chapter 11 operator overloading; string and array objects 434 11.1 introduction 435 11.2 fundamentals of operator overloading 435 11.3 restrictions on operator overloading 436 11.4 operator functions as class members vs. global functions 437 11.5 overloading stream insertion and stream extraction operators 438 11.6 overloading unary operators 441 11.7 overloading binary operators 441 11.8 case study: array class 442 11.9 converting between types 450 11.10 case study: string class 451 11.11 overloading ++ and -- 460 11.12 case study: a date class 461 11.13 standard library class string 464 11.14 explicit constructors 467 chapter 12 object-oriented programming: inheritance 480 12.1 introduction 481 12.2 base classes and derived classes 482 12.3 protected members 483 12.4 relationship between base classes and derived classes 484 12.4.1 creating and using a commissionemployee class 484 12.4.2 creating a basepluscommissionemployee class without using inheritance 488 12.4.3 creating a commissionemployee蠦asepluscommissionemployee inheritance hierarchy 492 12.4.4 commissionemployee蠦asepluscommissionemployee inheritance hierarchy using protected data 495 12.4.5 commissionemployee蠦asepluscommissionemployee inheritance hierarchy using private data 501 12.5 constructors and destructors in derived classes 506 12.6 public, protected and private inheritance 512 12.7 software engineering with inheritance 512 chapter 13 object-oriented programming: polymorphism 518 13.1 introduction 519 13.2 polymorphism examples 520 13.3 relationships among objects in an inheritance hierarchy 520 13.3.1 invoking base-class functions from derived-class objects 521 13.3.2 aiming derived-class pointers at base-class objects 526 13.3.3 derived-class member-function calls via base-class pointers 527 13.3.4 virtual functions 528 13.3.5 summary of the allowed assignments between base-class and derived-class objects and pointers 532 13.4 type fields and switch statements 533 13.5 abstract classes and pure virtual functions 534 13.6 case study: payroll system using polymorphism 535 13.6.1 creating abstract base class employee 536 13.6.2 creating concrete derived class salariedemployee 539 13.6.3 creating concrete derived class hourlyemployee 540 13.6.4 creating concrete derived class commissionemployee 542 13.6.5 creating indirect concrete derived class basepluscommissionemployee 543 13.6.6 demonstrating polymorphic processing 545 13.7 (optional) polymorphism, virtual functions and dynamic binding 襏nder the hood? 547 13.8 case study: payroll system using polymorphism and runtime type information with downcasting, dynamic_cast, typeid and type_info 550 13.9 virtual destructors 553 13.10 (optional) software engineering case study: incorporating inheritance into the atm system 553 chapter 14 templates 564 14.1 introduction 564 14.2 function templates 565 14.3 overloading function templates 567 14.4 class templates 568 14.5 nontype parameters and default types for class templates 572 14.6 notes on templates and inheritance 573 14.7 notes on templates and friends 573 14.8 notes on templates and static members 574 chapter 15 stream input/output 579 15.1 introduction 580 15.2 streams 580 15.2.1 classic streams vs. standard streams 581 15.2.2 iostream library header files 581 15.2.3 stream input/output classes and objects 581 15.3 stream output 583 15.3.1 output of char * variables 583 15.3.2 character output using member function put 583 15.4 stream input 584 15.4.1 get and getline member functions 584 15.4.2 istream member functions peek, putback and ignore 586 15.4.3 type-safe i/o 587 15.5 unformatted i/o using read, write and gcount 587 15.6 introduction to stream manipulators 588 15.6.1 integral stream base: dec, oct, hex and setbase 588 15.6.2 floating-point precision (precision, setprecision) 588 15.6.3 field width (width, setw) 589 15.6.4 user-de辬ed output stream manipulators 590 15.7 stream format states and stream manipulators 591 15.7.1 trailing zeros and decimal points (showpoint) 592 15.7.2 justi辌ation (left, right and internal) 593 15.7.3 padding (fill, setfill) 594 15.7.4 integral stream base (dec, oct, hex, showbase) 595 15.7.5 floating-point numbers; scienti辌 and fixed notation (scientific, fixed) 596 15.7.6 uppercase/lowercase control (uppercase) 596 15.7.7 specifying boolean format (boolalpha) 597 15.7.8 setting and resetting the format state via member function flags 598 15.8 stream error states 599 15.9 tying an output stream to an input stream 600 chapter 16 exception handling 610 16.1 introduction 611 16.2 exception-handling overview 611 16.3 example: handling an attempt to divide by zero 612 16.4 when to use exception handling 616 16.5 rethrowing an exception 617 16.6 exception specifications 618 16.7 processing unexpected exceptions 619 16.8 stack unwinding 619 16.9 constructors, destructors and exception handling 620 16.10 exceptions and inheritance 621 16.11 processing new failures 621 16.12 class auto_ptr and dynamic memory allocation 624 16.13 standard library exception hierarchy 626 16.14 other error-handling techniques 627 chapter 17 file processing 634 17.1 introduction 634 17.2 data hierarchy 635 17.3 files and streams 636 17.4 creating a sequential file 637 17.5 reading data from a sequential file 640 17.6 updating sequential files 644 17.7 random-access files 645 17.8 creating a random-access file 645 17.9 writing data randomly to a random-access file 649 17.10 reading from a random-access file sequentially 651 17.11 case study: a transaction-processing program 652 17.12 overview of object serialization 657 chapter 18 class string and string stream processing 667 18.1 introduction 668 18.2 string assignment and concatenation 669 18.3 comparing strings 670 18.4 substrings 672 18.5 swapping strings 673 18.6 string characteristics 673 18.7 finding substrings and characters in a string 675 18.8 replacing characters in a string 676 18.9 inserting characters into a string 678 18.10 conversion to c-style pointer-based char * strings 679 18.11 iterators 680 18.12 string stream processing 681 chapter 19 searching and sorting 688 19.1 introduction 688 19.2 searching algorithms 689 19.2.1 efficiency of linear search 689 19.2.2 binary search 690 19.3 sorting algorithms 694 19.3.1 efficiency of selection sort 694 19.3.2 efficiency of insertion sort 695 19.3.3 merge sort (a recursive implementation) 695 chapter 20 data structures 705 20.1 introduction 705 20.2 self-referential classes 706 20.3 dynamic memory allocation and data structures 707 20.4 linked lists 707 20.5 stacks 718 20.6 queues 721 20.7 trees 724 chapter 21 standard template library (stl) 749 21.1 introduction to the standard template library(stl) 750 21.1.1 introduction to containers 751 21.1.2 introduction to iterators 754 21.1.3 introduction to algorithms 758 21.2 sequence containers 759 21.2.1 vector sequence container 760 21.2.2 list sequence container 765 21.2.3 deque sequence container 768 21.3 associative containers 769 21.3.1 multiset associative container 769 21.3.2 set associative container 771 21.3.3 multimap associative container 773 21.3.4 map associative container 774 21.4 container adapters 775 21.4.1 stack adapter 775 21.4.2 queue adapter 777 21.4.3 priority_queue adapter 778 21.5 algorithms 779 21.5.1 fill, fill_n, generate and generate_n 779 21.5.2 equal, mismatch and lexicographical_compare 781 21.5.3 remove, remove_if, remove_copy and remove_copy_if 782 21.5.4 replace, replace_if, replace_copy and replace_copy_if 784 21.5.5 mathematical algorithms 786 21.5.6 basic searching and sorting algorithms 788 21.5.7 swap, iter_swap and swap_ranges 790 21.5.8 copy_backward, merge, unique and reverse 791 21.5.9 inplace_merge, unique_copy and reverse_copy 793 21.5.10 set operations 794 21.5.11 lower_bound, upper_bound and equal_range 796 21.5.12 heapsort 798 21.5.13 min and max 800 21.5.14 stl algorithms not covered in this chapter 800 21.6 class bitset 801 21.7 function objects 804 21.8 stl web resources 806 chapter 22 game programming with ogre 815 22.1 introduction 816 22.2 installing ogre, ogreal and openal 816 22.3 basics of game programming 816 22.4 the game of pong: code walkthrough 818 22.4.1 ogre initialization 819 22.4.2 creating a scene 825 22.4.3 adding to the scene 826 22.4.4 animation and timers 834 22.4.5 user input 835 22.4.6 collision detection 836 22.4.7 sound 838 22.4.8 resources 838 22.4.9 pong driver 838 22.5 ogre web resources 839 chapter 23 boostlibraries, technical report 1 and c++0x 847 23.1 introduction 848 23.2 deitel online c++ and related resource centers 848 23.3 boost libraries 848 23.4 adding a new library to boost 848 23.5 installing the boost libraries 849 23.6 boost libraries in technical report 1 (tr1) 849 23.7 regular expressions with the boost.regex library 851 23.7.1 regular expression example 852 23.7.2 validating user input with regular expressions 854 23.7.3 replacing and splitting strings 856 23.8 smart pointers with boost.smart_ptr 858 23.8.1 reference counted shared_ptr 858 23.8.2 weak_ptr: shared_ptr observer 861 23.9 technical report 1 865 23.10 c++0x 866 23.11 core language changes 867 chapter 24 other topics 878 24.1 introduction 878 24.2 const_cast operator 879 24.3 namespaces 880 24.4 operator keywords 883 24.5 mutable class members 884 24.6 pointers to class members (.* and ->*) 885 24.7 multiple inheritance 887 24.8 multiple inheritance and virtual base classes 890 appendix a operator precedence and associativity chart 898 appendix b ascii character set 900 appendix c fundamental types 901 appendix d number systems 902 appendix e c legacy code topics 912 appendix f preprocessor 931 appendix g atm case study code 941 appendix h uml 2: additional diagram types 964 appendix i using the visual studio debugger 965 appendix j using the gnu c++ debugger 976 bibliography 989 index 993 |
商品评论(0条)