C++ by Dissection presents a thorough introduction to the programming process by carefully developing working programs to illuminate key features of the C++ programming language. This book presents the concepts of the programming process using the "dissection" method, the hallmark feature that has made Ira Pohl's C and Java books of the "By Dissection" series so popular. Dissection is a unique pedagogical tool first developed by the author to point out key features of program code. It is similar to a structured walk-through of the code, with the intention of explaining newly encountered programming elements and idioms as found in working code. The book includes a CD-ROM containing a compiler and an electronic version of the book that allows readers to search, take notes, and highlight right on their computer. Each chapter presents a number of carefully explained programs, which lead the reader in a holistic manner to ever-improving programming skills. Right from the start, the reader is introduced to complete programs, and at an early point in the book, the reader is introduced to writing functions as a major feature of structured programming. It contains four to seven small code dissections per chapter, and then each chapter culminates with a larger, extended code dissection. "Software Engineering" sections in each chapter reinforce sound software engineering skills. The book assumes no programming background and can be used by first-time computer users or by experienced programmers who are transitioning to C++. Preface Dissections No Background Assumed Special Features Chapter Features Classroom Usage Interactive Environment Professional Use Supplements Acknowledgments Table of Contents A First Program Problem Solving: Recipes 1.2.1 Algorithms—Being Precise Implementing Our Algorithm in C++ Software Engineering: Style Common Programming Errors Writing and Running a C++ Program 1.6.1 Interrupting a Program 1.6.2 Typing an End-of-File Signal Dr. P’s Prescriptions C++ Compared with Java Summary Review Questions Exercises Writing an ANSI C++ Program Getting Ready to Program Program Elements 2.1.1 Comments 2.1.2 Keywords 2.1.3 Identifiers 2.1.4 Literals 2.1.5 Operators and Punctuators Input/Output Program Structure 2.3.1 Redirection Simple Types 2.4.1 Initialization The Traditional Conversions Enumeration Types 2.6.1 typedef Declarations Expressions 2.7.1 Precedence and Associativity of Operators 2.7.2 Relational, Equality, and Logical Operators Statements 2.8.1 Assignment and Expressions 2.8.2 The Compound Statement 2.8.3 The if and if-else Statements 2.8.4 The while Statement 2.8.5 The for Statement 2.8.6 The do Statement 2.8.7 The break and continue Statements 2.8.8 The switch Statement 2.8.9 The goto Statement Software Engineering: Debugging Dr. P’s Prescriptions C++ Compared with Java Summary Review Questions Exercises Native Types and Statements Functions, Pointers, and Arrays Functions Function Invocation Function Definition The return Statement Function Prototypes Call-By-Value Recursion Default Arguments Functions as Arguments Overloading Functions Inlining 3.11.1 Software Engineering: Avoiding Macros Scope and Storage Class 3.12.1 The Storage Class auto 3.12.2 The Storage Class extern 3.12.3 The Storage Class register 3.12.4 The Storage Class static 3.12.5 Header Files and Linkage Mysteries Namespaces Pointer Types 3.14.1 Addressing and Dereferencing 3.14.2 Pointer-Based Call-By-Reference Reference Declarations The Uses of void Arrays 3.17.1 Subscripting 3.17.2 Initialization Arrays and Pointers Passing Arrays to Functions Problem Solving: Random Numbers Software Engineering: Structured Programming Core Language ADT: char* String Multidimensional Arrays Operators new and delete 3.24.1 Vector Instead of Array 3.24.2 String Instead of char* Software Engineering: Program Correctness Dr. P’s Prescriptions C++ Compared with Java Summary Review Questions Exercises The Aggregate Type class and struct Member Selection Operator Member Functions Access: Private and Public Classes Class Scope 4.6.1 Scope Resolution Operator 4.6.2 Nested Classes An Example: Flushing The this Pointer static Members const Members 4.10.1 Mutable Members A Container Class Example: ch_stack Software Engineering: Class Design 4.12.1 Trade-Offs in Design 4.12.2 Unified Modeling Language (UML) and Design Dr. P’s Prescriptions C++ Compared with Java Advanced Topics 4.15.1 Pointer to Class Member 4.15.2 Unions 4.15.3 Bit Fields Summary Review Questions Exercises Classes and Abstract Data Types Classes with Constructors 5.1.1 The Default Constructor 5.1.2 Constructor Initializer 5.1.3 Constructors as Conversions 5.1.4 Improving the point Class 5.1.5 Constructing a Stack 5.1.6 The Copy Constructor Classes with Destructors Members That Are Class Types Example: A Singly Linked List Strings Using Reference Semantics Constructor Issues and Mysteries 5.6.1 Destructor Details 5.6.2 Constructor Pragmatics Polymorphism Using Function Overloading ADT Conversions Overloading and Signature Matching Friend Functions Overloading Operators Unary Operator Overloading Binary Operator Overloading Overloading the Assignment Operator Overloading the Subscript Operator Overloading Operator () for Indexing Overloading < > Overloading -> Overloading new and delete More Signature Matching Software Engineering: When to Use Overloading Dr. P’s Prescriptions C++ Compared with Java Summary Review Questions Exercises Ctors, Dtors, Conversions, and Operator Overloading Templates and Generic Programming Template Class stack Function Templates 6.2.1 Signature Matching and Overloading 6.2.2 How to Write a Simple Function: square() Generic Code Development: Quicksort 6.3.1 Converting to a Generic quicksort() Class Templates 6.4.1 Friends 6.4.2 Static Members 6.4.3 Class Template Arguments 6.4.4 Default Template Arguments 6.4.5 Member Templates Parameterizing the Class vector Using STL: string, vector, and complex 6.6.1 string and basic_string 6.6.2 vector in STL 6.6.3 Using complex 6.6.4 limits and Other Useful Templates Software Engineering: Reuse and Generics 6.7.1 Debugging Template Code 6.7.2 Special Considerations 6.7.3 Using typename Dr. P’s Prescriptions C++ Compared with Java Summary Review Questions Exercises Standard Template Library A Simple STL Example Containers 7.2.1 Sequence Containers 7.2.2 Associative Containers 7.2.3 Container Adaptors Iterators 7.3.1 Iterators for istream and ostream 7.3.2 Iterator Adaptors Algorithms 7.4.1 Sorting Algorithms 7.4.2 Nonmutating Sequence Algorithms 7.4.3 Mutating Sequence Algorithms 7.4.4 Numerical Algorithms Numerical Integration Made Easy STL: Function Objects 7.6.1 Building a Function Object 7.6.2 Function Adaptors Allocators Software Engineering: STL Use 7.8.1 Syntax Bugs Dr. P’s Prescriptions C++ Compared with Java Summary Review Questions Exercises Inheritance and OOP A Derived Class 8.1.1 More Unified Modeling Language (UML) A Student ISA Person Virtual Functions: Dynamic Determination 8.3.1 Overloading and Overriding Confusion 8.3.2 A Canonical Example: Class shape Abstract Base Classes Templates and Inheritance Multiple Inheritance RTTI and Other Fine Points 8.7.1 Finer Points Software Engineering: Inheritance and Design 8.8.1 Subtyping Form 8.8.2 Code Reuse Dr. P’s Prescriptions C++ Compared with Java Summary Review Questions Exercises Input/Output The Output Class ostream Formatted Output and iomanip User-Defined Types: Output The Input Class istream Files Using Strings as Streams The Functions and Macros in ctype Using Stream States Mixing I/O Libraries Software Engineering: I/O Dr. P’s Prescriptions C++ Compared with Java Summary Review Questions Exercises Exceptions and Program Correctness Using the assert Library C++ Exceptions Throwing Exceptions 10.3.1 Rethrown Exceptions 10.3.2 Exception Expressions try Blocks Handlers Converting Assertions to Exceptions Exception Specification terminate() and unexpected() Standard Exceptions and Their Uses Software Engineering: Exception Objects Dr. P’s Prescriptions C++ Compared with Java Summary Review Questions Exercises OOP Using C++ OOP Language Requirements 11.1.1 ADTs: Encapsulation and Data Hiding 11.1.2 Reuse and Inheritance 11.1.3 Polymorphism OOP: The Dominant Programming Methodology Designing with OOP in Mind Class-Responsibility-Collaborator 11.4.1 CRC Cards Design Patterns A Further Assessment of C++ 11.6.1 Why C++ Is Better Than Java 11.6.2 A Short Rebuttal Software Engineering: Last Thoughts Dr. P’s Prescriptions C++ Compared with Java Summary Review Questions Exercises ASCII Character Codes Operator Precedence and Associativity String Library Constructors Member Functions Global Operators The tio Library Console FormattedWriter PrintFileWriter ReadException ReadInput Index Provides an introduction to the programming process by developing working programs to illuminate key features of the C++ programming language. This book presents the concepts of the programming process using the "dissection" method. It can be used by first time computer users or by experienced programmers who are transitioning to C++. "This book provides a broad overview of the language, and thus can be used by first time computer users, by experienced programmers who are transitioning to C#, or by those who simply need a handy C# reference."--BOOK JACKET