C++ :
how to program /
Deitel, Paul J.
C++ : how to program /
C plus plus.
Paul Deitel, Harvey Deitel.
- Eighth edition
- Boston : Prentice Hall, c2012.
- xxxii, 1099 p. : ill. ; 24 cm.
- How to program series. .
Includes index.
1 Introduction to Computers and C++ 1 1.1 Introduction 2 1.2 Computers: Hardware and Software 5 1.3 Data Hierarchy 6 1.4 Computer Organization 7 1.5 Machine Languages, Assembly Languages and High-Level Languages 9 1.6 Introduction to Object Technology 10 1.7 Operating Systems 13 1.8 Programming Languages 15 1.9 C++ and a Typical C++ Development Environment 17 1.10 Test-Driving a C++ Application 21 1.11 Web 2.0: Going Social 27 1.12 Software Technologies 29 1.13 Future of C++: TR1, the New C++ Standard and the Open Source Boost Libraries 31 1.14 Keeping Up-to-Date with Information Technologies 32 1.15 Wrap-Up 32 2 Introduction to C++ Programming 37 2.1 Introduction 38 2.2 First Program in C++: Printing a Line of Text 38 2.3 Modifying Our First C++ Program 42 2.4 Another C++ Program: Adding Integers 43 2.5 Memory Concepts 47 2.6 Arithmetic 48 2.7 Decision Making: Equality and Relational Operators 51 2.8 Wrap-Up 55 3 Introduction to Classes, Objects and Strings 64 3.1 Introduction 65 3.2 Defining a Class with a Member Function 65 3.3 Defining a Member Function with a Parameter 68 3.4 Data Members, set Functions and get Functions 71 3.5 Initializing Objects with Constructors 77 3.6 Placing a Class in a Separate File for Reusability 81 3.7 Separating Interface from Implementation 84 3.8 Validating Data with set Functions 90 3.9 Wrap-Up 95 4 Control Statements: Part1 101 4.1 Introduction 102 4.2 Algorithms 102 4.3 Pseudocode 103 4.4 Control Structures 104 4.5 if Selection Statement 107 4.6 if…else Double-Selection Statement 108 4.7 while Repetition Statement 113 4.8 Formulating Algorithms: Counter-Controlled Repetition 114 4.9 Formulating Algorithms: Sentinel-Controlled Repetition 120 4.10 Formulating Algorithms: Nested Control Statements 130 4.11 Assignment Operators 134 4.12 Increment and Decrement Operators 135 4.13 Wrap-Up 138 5 Control Statements: Part2 152 5.1 Introduction 153 5.2 Essentials of Counter-Controlled Repetition 153 5.3 for Repetition Statement 155 5.4 Examples Using the for Statement 158 5.5 do…while Repetition Statement 162 5.6 switch Multiple-Selection Statement 164 5.7 break and continue Statements 173 5.8 Logical Operators 174 5.9 Confusing the Equality (==) and Assignment (=) Operators 179 5.10 Structured Programming Summary 180 5.11 Wrap-Up 185 6 Functions and an Introduction to Recursion 194 6.1 Introduction 195 6.2 Program Components in C++ 196 6.3 Math Library Functions 197 6.4 Function Definitions with Multiple Parameters 198 6.5 Function Prototypes and Argument Coercion 203 6.6 C++ Standard Library Headers 205 6.7 Case Study: Random Number Generation 207 6.8 Case Study: Game of Chance; Introducing enum 212 6.9 Storage Classes 215 6.10 Scope Rules 218 6.11 Function Call Stack and Activation Records 221 6.12 Functions with Empty Parameter Lists 225 6.13 Inline Functions 225 6.14 References and Reference Parameters 227 6.15 Default Arguments 231 6.16 Unary Scope Resolution Operator 232 6.17 Function Overloading 234 6.18 Function Templates 236 6.19 Recursion 239 6.20 Example Using Recursion: Fibonacci Series 242 6.21 Recursion vs. Iteration 245 6.22 Wrap-Up 248 7 Arrays and Vectors 267 7.1 Introduction 268 7.2 Arrays 269 7.3 Declaring Arrays 270 7.4 Examples Using Arrays 271 7.4.1 Declaring an Array and Using a Loop to Initialize the Array’s Elements 271 7.4.2 Initializing an Array in a Declaration with an Initializer List 272 7.4.3 Specifying an Array’s Size with a Constant Variable and Setting Array Elements with Calculations 273 7.4.4 Summing the Elements of an Array 275 7.4.5 Using Bar Charts to Display Array Data Graphically 276 7.4.6 Using the Elements of an Array as Counters 277 7.4.7 Using Arrays to Summarize Survey Results 278 7.4.8 Static Local Arrays and Automatic Local Arrays 281 7.5 Passing Arrays to Functions 283 7.6 Case Study: Class GradeBook Using an Array to Store Grades 287 7.7 Searching Arrays with Linear Search 293 7.8 Sorting Arrays with Insertion Sort 294 7.9 Multidimensional Arrays 297 7.10 Case Study: Class GradeBook Using a Two-Dimensional Array 300 7.11 Introduction to C++ Standard Library Class Template vector 307 7.12 Wrap-Up 313 8 Pointers 330 8.1 Introduction 331 8.2 Pointer Variable Declarations and Initialization 331 8.3 Pointer Operators 332 8.4 Pass-by-Reference with Pointers 335 8.5 Using const with Pointers 339 8.6 Selection Sort Using Pass-by-Reference 343 8.7 sizeof Operator 347 8.8 Pointer Expressions and Pointer Arithmetic 349 8.9 Relationship Between Pointers and Arrays 352 8.10 Pointer-Based String Processing 354 8.11 Arrays of Pointers 357 8.12 Function Pointers 358 8.13 Wrap-Up 361 9 Classes: A Deeper Look, Part1 379 9.1 Introduction 380 9.2 Time Class Case Study 381 9.3 Class Scope and Accessing Class Members 388 9.4 Separating Interface from Implementation 389 9.5 Access Functions and Utility Functions 390 9.6 Time Class Case Study: Constructors with Default Arguments 393 9.7 Destructors 398 9.8 When Constructors and Destructors Are Called 399 9.9 Time Class Case Study: A Subtle Trap–Returning a Reference to a private Data Member 402 9.10 Default Memberwise Assignment 405 9.11 Wrap-Up 407 10 Classes: A Deeper Look, Part2 414 10.1 Introduction 415 10.2 const (Constant) Objects and const Member Functions 415 10.3 Composition: Objects as Members of Classes 423 10.4 friend Functions and friend Classes 429 10.5 Using the this Pointer 431 10.6 static Class Members 436 10.7 Proxy Classes 441 10.8 Wrap-Up 445 11 Operator Overloading; Class string 451 11.1 Introduction 452 11.2 Using the Overloaded Operators of Standard Library Class string 453 11.3 Fundamentals of Operator Overloading 456 11.4 Overloading Binary Operators 457 11.5 Overloading the Binary Stream Insertion and Stream Extraction Operators 458 11.6 Overloading Unary Operators 462 11.7 Overloading the Unary Prefix and Postfix ++ and -- Operators 463 11.8 Case Study: A Date Class 464 11.9 Dynamic Memory Management 469 11.10 Case Study: Array Class 471 11.10.1 Using the Array Class 472 11.10.2 Array Class Definition 475 11.11 Operators as Member Functions vs. Non-Member Functions 483 11.12 Converting between Types 483 11.13 explicit Constructors 485 11.14 Building a String Class 487 11.15 Wrap-Up 488 12 Object-Oriented Programming: Inheritance 499 12.1 Introduction 500 12.2 Base Classes and Derived Classes 500 12.3 protected Members 503 12.4 Relationship between Base Classes and Derived Classes 503 12.4.1 Creating and Using a CommissionEmployee Class 504 12.4.2 Creating a BasePlusCommissionEmployee Class Without Using Inheritance 508 12.4.3 Creating a CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy 514 12.4.4 CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy Using protected Data 519 12.4.5 CommissionEmployee—BasePlusCommissionEmployee Inheritance Hierarchyructors and Destructors in Derived Classes 527 12.6 public, protected and private Inheritance 527 12.7 Software Engineering with Inheritance 528 12.8 Wrap-Up 529 13 Object-Oriented Programming: Polymorphism 534 13.1 Introduction 535 13.2 Introduction to Polymorphism: Polymorphic Video Game 536 13.3 Relationships Among Objects in an Inheritance Hierarchy 536 13.3.1 Invoking Base-Class Functions from Derived-Class Objects 537 13.3.2 Aiming Derived-Class Pointers at Base-Class Objects 540 13.3.3 Derived-Class Member-Function Calls via Base-Class Pointers 541 13.3.4 Virtual Functions 543 13.4 Type Fields and switch Statements 549 13.5 Abstract Classes and Pure virtual Functions 549 13.6 Case Study: Payroll System Using Polymorphism 551 13.6.1 Creating Abstract Base Class Employee 552 13.6.2 Creating Concrete Derived Class SalariedEmployee 556 13.6.3 Creating Concrete Derived Class CommissionEmployee 558 13.6.4 Creating Indirect Concrete Derived Class BasePlusCommissionEmployee 560 13.6.5 Demonstrating Polymorphic Processing 562 13.7 (Optional) Polymorphism, Virtual Functions and Dynamic Binding “Under the Hood” 566 13.8 Case Study: Payroll System Using Polymorphism and Runtime Type Information with Downcasting, dynamic_cast, typeid and type_info 569 13.9 Virtual Destructors 573 13.10 Wrap-Up 573 14 Templates 579 14.1 Introduction 580 14.2 Function Templates 580 14.3 Overloading Function Templates 583 14.4 Class Templates 584 14.5 Nontype Parameters and Default Types for Class Templates 590 14.6 Wrap-Up 591 15 Stream Input/Output 595 15.1 Introduction 596 15.2 Streams 597 15.2.1 Classic Streams vs. Standard Streams 597 15.2.2 iostream Library Headers 598 15.2.3 Stream Input/Output Classes and Objects 598 15.3 Stream Output 601 15.3.1 Output of char * Variables 601 15.3.2 Character Output Using Member Function put 601 15.4 Stream Input 602 15.4.1 get and getline Member Functions 602 15.4.2 istream Member Functions peek, putback and ignore 605 15.4.3 Type-Safe I/O 605 15.5 Unformatted I/O Using read, write and gcount 605 15.6 Introduction to StreamManipulators 606 15.6.1 Integral Stream Base: dec, oct, hex and setbase 607 15.6.2 Floating-Point Precision (precision, setprecision) 607 15.6.3 Field Width (width, setw) 609 15.6.4 User-Defined Output Stream Manipulators 610 15.7 Stream Format States and Stream Manipulators 612 15.7.1 Trailing Zeros and Decimal Points (showpoint) 612 15.7.2 Justification (left, right and internal) 613 15.7.3 Padding (fill, setfill) 615 15.7.4 Integral Stream Base (dec, oct, hex, showbase) 616 15.7.5 Floating-Point Numbers; Scientific and Fixed Notation (scientific, fixed) 617 15.7.6 Uppercase/Lowercase Control (uppercase) 618 15.7.7 Specifying Boolean Format (boolalpha) 618 15.7.8 Setting and Resetting the Format State via Member Function flags 619 15.8 Stream Error States 620 15.9 Tying an Output Stream to an Input Stream 622 15.10 Wrap-Up 623 16 Exception Handling: A Deeper Look 632 16.1 Introduction 633 16.2 Example: Handling an Attempt to Divide by Zero 633 16.3 When to Use Exception Handling 639 16.4 Rethrowing an Exception 640 16.5 Exception Specifications 641 16.6 Processing Unexpected Exceptions 642 16.7 Stack Unwinding 642 16.8 Constructors, Destructors and Exception Handling 644 16.9 Exceptions and Inheritance 645 16.10 Processing new Failures 645 16.11 Class unique_ptr and Dynamic Memory Allocation 648 16.12 Standard Library Exception Hierarchy 650 16.13 Wrap-Up 652 17 File Processing 658 17.1 Introduction 659 17.2 Files and Streams 659 17.3 Creating a Sequential File 660 17.4 Reading Data from a Sequential File 664 17.5 Updating Sequential Files 669 17.6 Random-Access Files 670 17.7 Creating a Random-Access File 671 17.8 Writing Data Randomly to a Random-Access File 675 17.9 Reading from a Random-Access File Sequentially 677 17.10 Case Study: A Transaction-Processing Program 679 17.11 Object Serialization 686 17.12 Wrap-Up 686 Contents xix A.15 C Blogs 1078 A.16 C Downloads from Download.com 1078 A.17 C Game Programming 1078 A.18 Allegro Game Programming Resources 1079 A.19 Jobs for C Programmers 1081 A.20 Deitel C Training 1081 B Operator Precedence Charts 1082 C ASCII Character Set 1086 D Number Systems 1087 D.1 Introduction 1088 D.2 Abbreviating Binary Numbers as Octal and Hexadecimal Numbers 1091 D.3 Converting Octal and Hexadecimal Numbers to Binary Numbers 1092 D.4 Converting from Binary, Octal or Hexadecimal to Decimal 1092 D.5 Converting from Decimal to Binary, Octal or Hexadecimal 1093 D.6 Negative Binary Numbers: Two’s Complement Notation 1095 E Game Programming: Solving Sudoku 1100 Index 1109
Access restricted to BGSU students, faculty and staff.
ISBN: 9780132662369 0132662361 9780273752769 0273752766
Subjects--Topical Terms: C++ (Computer program language)
Index Terms--Genre/Form: Electronic books.
LC Class. No.: QA76.73.C153 / D45 2012
Dewey Class. No.: 005.133 / D P C