digg.png delicious.png blinkit.png furl.png
C++ How to Program, Third Edition Table of Contents (Continued)
9 Inheritance 576

9.1 Introduction 577
9.2 Inheritance: Base Classes and Derived Classes 579
9.3 Protected Members 581
9.4 Casting Base-Class Pointers to Derived-Class Pointers 581
9.5 Using Member Functions 587
9.6 Overriding Base-Class Members in a Derived Class 587
9.7 public, protected and private Inheritance 592
9.8 Direct Base Classes and Indirect Base Classes 593
9.9 Using Constructors and Destructors in Derived Classes 593
9.10 Implicit Derived-Class Object to Base-Class Object Conversion 597
9.11 Software Engineering with Inheritance 598
9.12 Composition vs. Inheritance 599
9.13 “Uses A” and “Knows A” Relationships 600
9.14 Case Study: Point, Circle, Cylinder 600
9.15 Multiple Inheritance 607
9.16 [Optional Case Study] Thinking About Objects: Incorporating Inheritance into the Elevator Simulation 612

10 Virtual Functions and Polymorphism 625

10.1 Introduction 626
10.2 Type Fields and switch Statements 626
10.3 virtual Functions 627
10.4 Abstract Base Classes and Concrete Classes 628
10.5 Polymorphism 628
10.6 Case Study: A Payroll System Using Polymorphism 630
10.7 New Classes and Dynamic Binding 642
10.8 virtual Destructors 642
10.9 Case Study: Inheriting Interface and Implementation 643
10.10 Polymorphism, virtual Functions and Dynamic Binding “Under the Hood” 651

11 C++ Stream Input/Output 659

11.1 Introduction 661
11.2 Streams 661
11.2.1 Iostream Library Header Files 662
11.2.2 Stream Input/Output Classes and Objects 662
11.3 Stream Output 664
11.3.1 Stream-Insertion Operator 664
11.3.2 Cascading Stream-Insertion/Extraction Operators 666
11.3.3 Output of char * Variables 667
11.3.4 Character Output with Member Function put; Cascading puts 668
11.4 Stream Input 668
11.4.1 Stream-Extraction Operator 668
11.4.2 get and getline Member Functions 671
11.4.3 istream Member Functions peek, putback and ignore 674
11.4.4 Type-Safe I/O 674
11.5 Unformatted I/O with read, gcount and write 674
11.6 Stream Manipulators 675
11.6.1 Integral Stream Base: dec, oct, hex and setbase 675
11.6.2 Floating-Point Precision (precision, setprecision) 676
11.6.3 Field Width (setw, width) 678
11.6.4 User-Defined Manipulators 679
11.7 Stream Format States 680
11.7.1 Format State Flags 680
11.7.2 Trailing Zeros and Decimal Points (ios::showpoint) 681
11.7.3 Justification (ios::left, ios::right, ios::internal) 682
11.7.4 Padding (fill, setfill) 684
11.7.5 Integral Stream Base (ios::dec, ios::oct, ios::hex, ios::showbase) 686
11.7.6 Floating-Point Numbers; Scientific Notation (ios::scientific, ios::fixed) 687
11.7.7 Uppercase/Lowercase Control (ios::uppercase) 688
11.7.8 Setting and Resetting the Format Flags (flags, setiosflags, resetiosflags) 688
11.8 Stream Error States 690
11.9 Tying an Output Stream to an Input Stream 692

12 Templates 704

12.1 Introduction 705
12.2 Function Templates 706
12.3 Overloading Template Functions 709
12.4 Class Templates 709
12.5 Class Templates and Nontype Parameters 715
12.6 Templates and Inheritance 716
12.7 Templates and friends 716
12.8 Templates and static Members 717

Page 1 | 2 | 3 | 4 | 5 | 6