Sams Teach Yourself C++ in 21 Days

(singke) #1

Contents xix


           - Introduction


  • Week 1 At a Glance

    • Day 1 Getting Started

      • 2 The Anatomy of a C++ Program

      • 3 Working with Variables and Constants

      • 4 Creating Expressions and Statements

      • 5 Organizing into Functions

      • 6 Understanding Object-Oriented Programming

      • 7 More on Program Flow





  • Week 1 In Review

  • Week 2 At a Glance

    • Day 8 Understanding Pointers

      • 9 Exploiting References

      • 10 Working with Advanced Functions

      • 11 Object-Oriented Analysis and Design

      • 12 Implementing Inheritance

      • 13 Managing Arrays and Strings

      • 14 Polymorphism





  • Week 2 In Review

  • Week 3 At a Glance

    • Day 15 Special Classes and Functions

      • 16 Advanced Inheritance

      • 17 Working with Streams

      • 18 Creating and Using Namespaces

      • 19 Templates

      • 20 Handling Errors and Exceptions

      • 21 What’s Next





  • Week 3 In Review

    • Appendix A Working with Numbers: Binary and Hexadecimal Appendixes

      • B C++ Keywords

      • C Operator Precedence

      • D Answers

        • E A Look at Linked Lists

          • Index







    • Introduction Contents

    • Who Should Read This Book ..................................................................................

    • Conventions Used in This Book ..............................................................................

    • Sample Code for This Book ....................................................................................

    • Week 1 At a Glance

    • A Note to C Programmers ......................................................................................

    • Where You Are Going..............................................................................................



  • 1 Getting Started

    • A Brief History of C++ ..........................................................................................

      • The Need for Solving Problems ........................................................................

      • Procedural, Structured, and Object-Oriented Programming ..............................

      • Object-Oriented Programming (OOP) ..............................................................

      • C++ and Object-Oriented Programming ............................................................



    • How C++ Evolved ................................................................................................

    • Should I Learn C First? ........................................................................................

    • C++, Java, and C#..................................................................................................

    • Microsoft’s Managed Extensions to C++ ..............................................................

    • The ANSI Standard................................................................................................

    • Preparing to Program ............................................................................................

    • Your Development Environment ..........................................................................

    • The Process of Creating the Program ....................................................................

      • Creating an Object File with the Compiler ......................................................

      • Creating an Executable File with the Linker ..................................................



    • The Development Cycle ........................................................................................

    • HELLO.cpp—Your First C++ Program ..................................................................

    • Getting Started with Your Compiler ......................................................................

      • Building the Hello World Project ....................................................................



    • Compile Errors ......................................................................................................

    • Summary ................................................................................................................

    • Q&A ......................................................................................................................

    • Workshop ..............................................................................................................

      • Quiz ..................................................................................................................

      • Exercises ..........................................................................................................





  • 2 The Anatomy of a C++ Program

    • A Simple Program ................................................................................................

    • A Brief Look at cout............................................................................................

    • Using the Standard Namespace ............................................................................

    • Commenting Your Programs..................................................................................

      • Types of Comments ..........................................................................................

      • Using Comments ..............................................................................................

      • A Final Word of Caution About Comments ....................................................



    • Functions................................................................................................................

      • Using Functions................................................................................................

      • Methods Versus Functions................................................................................



    • Summary ................................................................................................................

    • Q&A ......................................................................................................................

    • Workshop ..............................................................................................................

      • Quiz ..................................................................................................................

      • Exercises ..........................................................................................................





  • 3 Working with Variables and Constants

    • What Is a Variable? ................................................................................................

      • Storing Data in Memory ..................................................................................

      • Setting Aside Memory......................................................................................

      • Size of Integers ................................................................................................

      • signedand unsigned........................................................................................

      • Fundamental Variable Types ............................................................................



    • Defining a Variable ................................................................................................

      • Case Sensitivity ................................................................................................

      • Naming Conventions ........................................................................................

      • Keywords ..........................................................................................................



    • Creating More Than One Variable at a Time ........................................................

    • Assigning Values to Your Variables ......................................................................

    • Creating Aliases with typedef..............................................................................

    • When to Use shortand When to Use long..........................................................

      • Wrapping Around an unsignedInteger............................................................

      • Wrapping Around a signedInteger..................................................................



    • Working with Characters ......................................................................................

      • Characters and Numbers ..................................................................................

      • Special Printing Characters ..............................................................................



    • Constants................................................................................................................

      • Literal Constants ..............................................................................................

      • Symbolic Constants ..........................................................................................



    • Enumerated Constants ..........................................................................................

    • Summary ................................................................................................................

    • Q&A ......................................................................................................................

    • Workshop ..............................................................................................................

      • Quiz ..................................................................................................................

      • Exercises ..........................................................................................................





  • 4 Creating Expressions and Statements

    • Starting with Statements ........................................................................................

      • Using Whitespace ............................................................................................

      • Blocks and Compound Statements ..................................................................



    • Expressions ............................................................................................................

    • Working with Operators ........................................................................................

      • Assignment Operators ......................................................................................

      • Mathematical Operators ..................................................................................



    • Combining the Assignment and Mathematical Operators ....................................

    • Incrementing and Decrementing............................................................................

      • Prefixing Versus Postfixing ..............................................................................



    • Understanding Operator Precedence ....................................................................

    • Nesting Parentheses ..............................................................................................

    • The Nature of Truth ..............................................................................................

      • Evaluating with the Relational Operators ........................................................



    • The ifStatement ..................................................................................................

      • Indentation Styles ............................................................................................

      • The elseStatement ..........................................................................................

      • Advanced ifStatements ..................................................................................



    • Using Braces in Nested ifStatements ..................................................................

    • Using the Logical Operators..................................................................................

      • The Logical ANDOperator ................................................................................

      • The Logical OROperator ..................................................................................

      • The Logical NOTOperator ................................................................................



    • Short Circuit Evaluation ........................................................................................

    • Relational Precedence............................................................................................

    • More About Truth and Falsehood ..........................................................................

    • The Conditional (Ternary) Operator ......................................................................

    • Summary ................................................................................................................

    • Q&A ......................................................................................................................

    • Workshop ..............................................................................................................

      • Quiz ..................................................................................................................

      • Exercises ..........................................................................................................





  • 5 Organizing into Functions

    • What Is a Function? ............................................................................................

    • Return Values, Parameters, and Arguments ........................................................

    • Declaring and Defining Functions ......................................................................

      • Function Prototypes........................................................................................

      • Defining the Function ....................................................................................



    • Execution of Functions ........................................................................................

    • Determining Variable Scope ................................................................................

      • Local Variables ..............................................................................................

      • Local Variables Within Blocks ......................................................................



    • Parameters Are Local Variables ..........................................................................

      • Global Variables..............................................................................................

      • Global Variables: A Word of Caution ............................................................



    • Considerations for Creating Function Statements ..............................................

    • More About Function Arguments ........................................................................

    • More About Return Values ..................................................................................

    • Default Parameters ..............................................................................................

    • Overloading Functions ........................................................................................

    • Special Topics About Functions ..........................................................................

      • Inline Functions ..............................................................................................

      • Recursion ........................................................................................................



    • How Functions Work—A Peek Under the Hood ................................................

      • Levels of Abstraction......................................................................................



    • Summary ..............................................................................................................

    • Q&A ....................................................................................................................

    • Workshop ............................................................................................................

      • Quiz ................................................................................................................

      • Exercises ........................................................................................................





  • 6 Understanding Object-Oriented Programming

    • Is C++ Object-Oriented? ....................................................................................

    • Creating New Types ............................................................................................

    • Introducing Classes and Members ......................................................................

      • Declaring a Class............................................................................................

      • A Word on Naming Conventions ..................................................................

      • Defining an Object ........................................................................................

      • Classes Versus Objects ..................................................................................



    • Accessing Class Members ..................................................................................

      • Assigning to Objects, Not to Classes ............................................................

      • If You Don’t Declare It, Your Class Won’t Have It ........................................



    • Private Versus Public Access ..............................................................................

      • Making Member Data Private ........................................................................



    • Implementing Class Methods ..............................................................................

    • Adding Constructors and Destructors..................................................................

      • Getting a Default Constructor and Destructor ..............................................

      • Using the Default Constructor........................................................................



    • Including const Member Functions ....................................................................

    • Interface Versus Implementation ........................................................................

    • Where to Put Class Declarations and Method Definitions..................................

    • Inline Implementation..........................................................................................

    • Classes with Other Classes as Member Data ......................................................

    • Exploring Structures ............................................................................................

    • Summary ..............................................................................................................

    • Q&A ....................................................................................................................

    • Workshop ............................................................................................................

      • Quiz ................................................................................................................

      • Exercises ........................................................................................................





  • 7 More on Program Flow

    • Looping ................................................................................................................

      • The Roots of Looping:goto..........................................................................

      • Why gotoIs Shunned ....................................................................................



    • Using whileLoops ..............................................................................................

      • Exploring More Complicated whileStatements............................................

      • Introducing continueand break....................................................................

      • Examining while (true)Loops....................................................................



    • Implementing do...whileLoops ........................................................................

    • Using do...while................................................................................................

    • Looping with the forStatement ..........................................................................

      • Advanced forLoops ......................................................................................

      • Empty forLoops............................................................................................

      • Nesting Loops ................................................................................................

      • Scoping in forLoops ....................................................................................



    • Summing Up Loops ............................................................................................

    • Controlling Flow with switchStatements ..........................................................

      • Using a switchStatement with a Menu ........................................................



    • Summary ..............................................................................................................

    • Q&A ....................................................................................................................

    • Workshop ............................................................................................................

      • Quiz ................................................................................................................

      • Exercises ........................................................................................................



    • Week 1 In Review

    • Week 2 At a Glance

    • Where You Are Going..........................................................................................



  • 8 Understanding Pointers

    • What Is a Pointer?................................................................................................

      • A Bit About Memory......................................................................................

      • Getting a Variable’s Memory Address............................................................

      • Storing a Variable’s Address in a Pointer ......................................................

      • Pointer Names ................................................................................................

      • Getting the Value from a Variable ..................................................................

      • Dereferencing with the Indirection Operator ................................................

      • Pointers, Addresses, and Variables ................................................................

      • Manipulating Data by Using Pointers ............................................................

      • Examining the Address ..................................................................................



    • Why Would You Use Pointers?............................................................................

    • The Stack and the Free Store (Heap) ..................................................................

      • Allocating Space with the newKeyword ........................................................

      • Putting Memory Back: The deleteKeyword ................................................



    • Another Look at Memory Leaks ........................................................................

    • Creating Objects on the Free Store......................................................................

    • Deleting Objects from the Free Store ..................................................................

    • Accessing Data Members ....................................................................................

    • Creating Member Data on the Free Store............................................................

    • The thisPointer ..................................................................................................

    • Stray, Wild, or Dangling Pointers ........................................................................

    • Using constPointers ..........................................................................................

      • constPointers and constMember Functions................................................

      • Using a const thisPointers..........................................................................



    • Summary ..............................................................................................................

    • Q&A ....................................................................................................................

    • Workshop ............................................................................................................

      • Quiz ................................................................................................................

      • Exercises ........................................................................................................





  • 9 Exploiting References

    • What Is a Reference? ..........................................................................................

    • Using the Address-Of Operator (&) on References..............................................

      • Attempting to Reassign References (Not!) ....................................................



    • Referencing Objects ............................................................................................

    • Null Pointers and Null References ......................................................................

    • Passing Function Arguments by Reference ........................................................

      • Making swap()Work with Pointers ..............................................................

      • Implementing swap()with References ..........................................................



    • Understanding Function Headers and Prototypes ..............................................

    • Returning Multiple Values ..................................................................................

      • Returning Values by Reference ......................................................................



    • Passing by Reference for Efficiency....................................................................

      • Passing a constPointer ..................................................................................

      • References as an Alternative ..........................................................................



    • Knowing When to Use References Versus Pointers ............................................

    • Mixing References and Pointers..........................................................................

    • Returning Out-of-Scope Object References ........................................................

      • Returning a Reference to an Object on the Heap ..........................................



    • Pointer, Pointer, Who Has the Pointer? ..............................................................

    • Summary ..............................................................................................................

    • Q&A ....................................................................................................................

    • Workshop ............................................................................................................

      • Quiz ................................................................................................................

      • Exercises ........................................................................................................





  • 10 Working with Advanced Functions

    • Overloaded Member Functions ..........................................................................

    • Using Default Values ..........................................................................................

    • Choosing Between Default Values and Overloaded Functions ..........................

    • The Default Constructor ......................................................................................

    • Overloading Constructors ....................................................................................

    • Initializing Objects ..............................................................................................

    • The Copy Constructor..........................................................................................

    • Operator Overloading ..........................................................................................

      • Writing an Increment Function ......................................................................

      • Overloading the Prefix Operator ....................................................................

      • Returning Types in Overloaded Operator Functions......................................

      • Returning Nameless Temporaries ..................................................................

      • Using the thisPointer ..................................................................................

      • Overloading the Postfix Operator ..................................................................

      • Difference Between Prefix and Postfix ..........................................................

      • Overloading Binary Mathematical Operators ................................................

      • Issues in Operator Overloading ......................................................................

      • Limitations on Operator Overloading ............................................................

      • What to Overload ..........................................................................................

      • The Assignment Operator ..............................................................................



    • Handling Data Type Conversion..........................................................................

    • Conversion Operators ..........................................................................................

    • Summary ..............................................................................................................

    • Q&A ....................................................................................................................

    • Workshop ............................................................................................................

      • Quiz ................................................................................................................

      • Exercises ........................................................................................................





  • 11 Object-Oriented Analysis and Design

    • Building Models ..................................................................................................

    • Software Design: The Modeling Language ........................................................

    • Software Design: The Process ............................................................................

      • Waterfall Versus Iterative Development ........................................................

      • The Process of Iterative Development ..........................................................



    • Step 1: The Conceptualization Phase: Starting with The Vision ........................

    • Step 2: The Analysis Phase: Gathering Requirements ........................................

      • Use Cases........................................................................................................

      • Application Analysis ......................................................................................

      • Systems Analysis ............................................................................................

      • Planning Documents ......................................................................................

      • Visualizations..................................................................................................

      • Artifacts ..........................................................................................................



    • Step 3: The Design Phase ....................................................................................

      • What Are the Classes?....................................................................................

      • Transformations ..............................................................................................

      • Other Transformations....................................................................................

      • Building the Static Model ..............................................................................

      • Dynamic Model ..............................................................................................



    • Steps 4–6: Implementation, Testing, and Rollout?..............................................

    • Iterations ..............................................................................................................

    • Summary ..............................................................................................................

    • Q&A ....................................................................................................................

    • Workshop ............................................................................................................

      • Quiz ................................................................................................................

      • Exercises ........................................................................................................





  • 12 Implementing Inheritance

    • What Is Inheritance? ............................................................................................

      • Inheritance and Derivation ............................................................................

      • The Animal Kingdom ....................................................................................

      • The Syntax of Derivation ..............................................................................



    • Private Versus Protected ......................................................................................

    • Inheritance with Constructors and Destructors ..................................................

      • Passing Arguments to Base Constructors ......................................................



    • Overriding Base Class Functions ........................................................................

      • Hiding the Base Class Method ......................................................................

      • Calling the Base Method ................................................................................



    • Virtual Methods ..................................................................................................

      • How Virtual Functions Work ..........................................................................

      • Trying to Access Methods from a Base Class................................................

      • Slicing ............................................................................................................

      • Creating Virtual Destructors ..........................................................................

      • Virtual Copy Constructors ..............................................................................

      • The Cost of Virtual Methods ..........................................................................



    • Summary ..............................................................................................................

    • Q&A ....................................................................................................................

    • Workshop ............................................................................................................

      • Quiz ................................................................................................................

      • Exercises ........................................................................................................





  • 13 Managing Arrays and Strings

    • What Is an Array? ................................................................................................

      • Accessing Array Elements..............................................................................

      • Writing Past the End of an Array ..................................................................

      • Fence Post Errors............................................................................................

      • Initializing Arrays ..........................................................................................

      • Declaring Arrays ............................................................................................



    • Using Arrays of Objects ......................................................................................

      • Declaring Multidimensional Arrays ..............................................................

      • Initializing Multidimensional Arrays ............................................................



    • Building Arrays of Pointers ................................................................................

    • A Look at Pointer Arithmetic—An Advanced Topic ..........................................

    • Declaring Arrays on the Free Store ....................................................................

      • A Pointer to an Array Versus an Array of Pointers ........................................

      • Pointers and Array Names..............................................................................

      • Deleting Arrays on the Free Store ..................................................................

      • Resizing Arrays at Runtime............................................................................



    • charArrays and Strings ......................................................................................

    • Using the strcpy()and strncpy()Methods ......................................................

    • String Classes ......................................................................................................

    • Linked Lists and Other Structures ......................................................................

    • Creating Array Classes ........................................................................................

    • Summary ..............................................................................................................

    • Q&A ....................................................................................................................

    • Workshop ............................................................................................................

      • Quiz ................................................................................................................

      • Exercises ........................................................................................................





  • 14 Polymorphism

    • Problems with Single Inheritance........................................................................

      • Percolating Upward ........................................................................................

      • Casting Down ................................................................................................

      • Adding to Two Lists ......................................................................................



    • Multiple Inheritance ............................................................................................

      • The Parts of a Multiply Inherited Object ......................................................

      • Constructors in Multiply Inherited Objects....................................................

      • Ambiguity Resolution ....................................................................................

      • Inheriting from Shared Base Class ................................................................

      • Virtual Inheritance ..........................................................................................

      • Problems with Multiple Inheritance ..............................................................

      • Mixins and Capabilities Classes ....................................................................



    • Abstract Data Types ............................................................................................

      • Pure Virtual Functions ....................................................................................

      • Implementing Pure Virtual Functions ............................................................

      • Complex Hierarchies of Abstraction ..............................................................

      • Which Classes Are Abstract? ........................................................................



    • Summary ..............................................................................................................

    • Q&A ....................................................................................................................

    • Workshop ............................................................................................................

      • Quiz ................................................................................................................

      • Exercises ........................................................................................................



    • Week 2 In Review

    • Week 3 At a Glance

    • Where You Are Going..........................................................................................



  • 15 Special Classes and Functions

    • Sharing Data Among Objects of the Same Type: Static Member Data ..............

    • Using Static Member Functions ..........................................................................

    • Pointers to Functions ..........................................................................................

      • Why Use Function Pointers?..........................................................................

      • Arrays of Pointers to Functions......................................................................

      • Passing Pointers to Functions to Other Functions ........................................

      • Using typedefwith Pointers to Functions ....................................................



    • Pointers to Member Functions ............................................................................

      • Arrays of Pointers to Member Functions ......................................................



    • Summary ..............................................................................................................

    • Q&A ....................................................................................................................

    • Workshop ............................................................................................................

      • Quiz ................................................................................................................

      • Exercises ........................................................................................................





  • 16 Advanced Inheritance

    • Aggregation..........................................................................................................

      • Accessing Members of the Aggregated Class ................................................

      • Controlling Access to Aggregated Members..................................................

      • Cost of Aggregation........................................................................................

      • Copying by Value ..........................................................................................



    • Implementation in Terms of Inheritance Versus Aggregation/Delegation ..........

      • Using Delegation ............................................................................................



    • Private Inheritance ..............................................................................................

    • Adding Friend Classes ........................................................................................

    • Friend Functions ..................................................................................................

    • Friend Functions and Operator Overloading ......................................................

    • Overloading the Insertion Operator ....................................................................

    • Summary ..............................................................................................................

    • Q&A ....................................................................................................................

    • Workshop ............................................................................................................

      • Quiz ................................................................................................................

      • Exercises ........................................................................................................





  • 17 Working with Streams

    • Overview of Streams ..........................................................................................

      • Encapsulation of Data Flow ..........................................................................

      • Understanding Buffering ................................................................................



    • Streams and Buffers ............................................................................................

    • Standard I/O Objects............................................................................................

    • Redirection of the Standard Streams ..................................................................

    • Input Using cin....................................................................................................

      • Inputting Strings ............................................................................................

      • String Problems ..............................................................................................

      • The cinReturn Value ....................................................................................



    • Other Member Functions of cin..........................................................................

      • Single Character Input....................................................................................

      • Getting Strings from Standard Input ..............................................................

      • Using cin.ignore()......................................................................................

      • Peeking at and Returning Characters:peek()and putback()......................



    • Outputting with cout..........................................................................................

      • Flushing the Output ........................................................................................

      • Functions for Doing Output ..........................................................................

      • Manipulators, Flags, and Formatting Instructions ........................................



    • Streams Versus the printf()Function................................................................

    • File Input and Output ..........................................................................................

    • Using the ofstream..............................................................................................

      • Condition States..............................................................................................

      • Opening Files for Input and Output ..............................................................

      • Changing the Default Behavior of ofstreamon Open ..................................



    • Binary Versus Text Files ......................................................................................

    • Command-line Processing ..................................................................................

    • Summary ..............................................................................................................

    • Q&A ....................................................................................................................

    • Workshop ............................................................................................................

      • Quiz ................................................................................................................

      • Exercises ........................................................................................................





  • 18 Creating and Using Namespaces

    • Getting Started ....................................................................................................

    • Resolving Functions and Classes by Name ........................................................

      • Visibility of Variables ....................................................................................

      • Linkage ..........................................................................................................

      • Static Global Variables ..................................................................................



    • Creating a Namespace ........................................................................................

      • Declaring and Defining Types ........................................................................

      • Defining Functions Outside a Namespace ....................................................

      • Adding New Members ..................................................................................

      • Nesting Namespaces ......................................................................................



    • Using a Namespace..............................................................................................

    • The usingKeyword ............................................................................................

      • The usingDirective........................................................................................

      • The usingDeclaration....................................................................................



    • The Namespace Alias ..........................................................................................

    • The Unnamed Namespace ..................................................................................

    • The Standard Namespace std..............................................................................

    • Summary ..............................................................................................................

    • Q&A ....................................................................................................................

    • Workshop ............................................................................................................

      • Quiz ................................................................................................................

      • Exercises ........................................................................................................





  • 19 Templates

    • What Are Templates? ..........................................................................................

    • Building a Template Definition ..........................................................................

      • Using the Name ..............................................................................................

      • Implementing the Template ............................................................................



    • Passing Instantiated Template Objects to Functions ..........................................

    • Templates and Friends ........................................................................................

      • Nontemplate Friend Classes and Functions ..................................................

      • General Template Friend Class or Function ..................................................



    • Using Template Items ..........................................................................................

      • Using Specialized Functions ..........................................................................

      • Static Members and Templates ......................................................................



    • The Standard Template Library ..........................................................................

      • Using Containers ............................................................................................

      • Understanding Sequence Containers..............................................................

      • Understanding Associative Containers ..........................................................

      • Working with the Algorithm Classes ............................................................



    • Summary ..............................................................................................................

    • Q&A ....................................................................................................................

    • Workshop ............................................................................................................

      • Quiz ................................................................................................................

      • Exercises ........................................................................................................





  • 20 Handling Errors and Exceptions

    • Bugs, Errors, Mistakes, and Code Rot ................................................................

      • Exceptional Circumstances ............................................................................



    • The Idea Behind Exceptions................................................................................

      • The Parts of Exception Handling ..................................................................

      • Causing Your Own Exceptions ......................................................................

      • Creating an Exception Class ..........................................................................



    • Placing tryBlocks and catchBlocks ................................................................

    • How Catching Exceptions Work..........................................................................

      • Using More Than One catchSpecification ..................................................

      • Exception Hierarchies ....................................................................................



    • Data in Exceptions and Naming Exception Objects ..........................................

    • Exceptions and Templates ..................................................................................

    • Exceptions Without Errors ..................................................................................

    • A Word About Code Rot......................................................................................

    • Bugs and Debugging............................................................................................

      • Breakpoints ....................................................................................................

      • Watch Points ..................................................................................................

      • Examining Memory........................................................................................

      • Assembler ......................................................................................................



    • Summary ..............................................................................................................

    • Q&A ....................................................................................................................

    • Workshop ............................................................................................................

      • Quiz ................................................................................................................

      • Exercises ........................................................................................................





  • 21 What’s Next

    • The Preprocessor and the Compiler ....................................................................

    • The #definePreprocessor Directive....................................................................

      • Using #definefor Constants..........................................................................

      • Using #definefor Tests ................................................................................

      • The #elsePrecompiler Command ................................................................



    • Inclusion and Inclusion Guards ..........................................................................

    • Macro Functions ..................................................................................................

      • Why All the Parentheses? ..............................................................................



    • String Manipulation ............................................................................................

      • Stringizing ......................................................................................................

      • Concatenation ................................................................................................





  • Predefined Macros ..............................................................................................

  • The assert()Macro............................................................................................

    • Debugging with assert()..............................................................................

    • Using assert()Versus Exceptions ................................................................

    • Side Effects ....................................................................................................

    • Class Invariants ..............................................................................................

    • Printing Interim Values ..................................................................................



  • Inline Functions ..................................................................................................

  • Bit Twiddling ......................................................................................................

    • Operator AND ................................................................................................

    • Operator OR ..................................................................................................

    • Operator Exclusive OR ..................................................................................

    • The Complement Operator ............................................................................

    • Setting Bits ....................................................................................................

    • Clearing Bits ..................................................................................................

    • Flipping Bits ..................................................................................................

    • Bit Fields ........................................................................................................



  • Programming Style ..............................................................................................

    • Indenting ........................................................................................................

    • Braces ............................................................................................................

    • Long Lines and Function Length ..................................................................

    • Structuring switchStatements ......................................................................

    • Program Text ..................................................................................................

    • Naming Identifiers ..........................................................................................

    • Spelling and Capitalization of Names............................................................

    • Comments ......................................................................................................

    • Setting Up Access ..........................................................................................

    • Class Definitions ............................................................................................

    • includeFiles ..................................................................................................

    • Using assert()..............................................................................................

    • Making Items Constant with const................................................................



  • Next Steps in Your C++ Development ................................................................

    • Where to Get Help and Advice ......................................................................

    • Related C++ Topics: Managed C++, C#, and Microsoft’s .NET ..................

    • Staying in Touch ............................................................................................



  • Summary ..............................................................................................................

  • Q&A ....................................................................................................................

  • Workshop ............................................................................................................

    • Quiz ................................................................................................................

    • Exercises ........................................................................................................



  • Week 3 In Review

  • A Working with Numbers: Binary and Hexadecimal

    • Using Other Bases ..............................................................................................

    • Converting to Different Bases ............................................................................

      • Binary ............................................................................................................

      • Why Base 2? ..................................................................................................

      • Bits, Bytes, and Nybbles ................................................................................

      • What’s a KB?..................................................................................................

      • Binary Numbers..............................................................................................



    • Hexadecimal ........................................................................................................

    • B C++ Keywords

    • C Operator Precedence



  • D Answers

    • Day 1....................................................................................................................

      • Quiz ................................................................................................................

      • Exercises ........................................................................................................



    • Day 2....................................................................................................................

      • Quiz ................................................................................................................

      • Exercises ........................................................................................................



    • Day 3....................................................................................................................

      • Quiz ................................................................................................................

      • Exercises ........................................................................................................



    • Day 4....................................................................................................................

      • Quiz ................................................................................................................

      • Exercises ........................................................................................................



    • Day 5....................................................................................................................

      • Quiz ................................................................................................................

      • Exercises ........................................................................................................



    • Day 6....................................................................................................................

      • Quiz ................................................................................................................

      • Exercises ........................................................................................................



    • Day 7....................................................................................................................

      • Quiz ................................................................................................................

      • Exercises ........................................................................................................



    • Day 8....................................................................................................................

      • Quiz ................................................................................................................

      • Exercises ........................................................................................................



    • Day 9....................................................................................................................

      • Quiz ................................................................................................................

      • Exercises ........................................................................................................





Free download pdf