CITATION

Kent, Jeff. C++ Demystified. US: McGraw-Hill Osborne Media, 2004.

C++ Demystified

Authors:

Published:  April 2004

eISBN: 9780071469968 0071469966 | ISBN: 9780072253702
  • Terms of Use
  • Want to learn more?
  • Contents at a Glance
  • About the Author
  • Contents
  • Acknowledgments & Introduction
  • Why Did I Write this Book?
  • Who Should Read this Book
  • What this Book Covers
  • How to Read this Book
  • Special Features
  • Contacting the Author
  • Chapter 1 How a C++ Program Works
  • What Is a Computer Program?
  • What Is a Programming Language?
  • Anatomy of a C++ Program
  • The main Function
  • The Function Body
  • cout
  • The return 0 Statement
  • The #include Directive
  • Namespace
  • Translating the Code for the Computer
  • Preprocessor
  • Compiler
  • Linker
  • Using an IDE to Create and Run the "Hello World!" Project
  • Setting Up the "Hello World!" Project
  • Writing the Source Code
  • Building the Project
  • Running the Code
  • Quiz
  • Chapter 2 Memory and Data Types
  • Memory
  • Types of Memory
  • Addresses
  • Bits and Bytes
  • Binary Numbering System
  • Converting Between Decimal and Binary or Hexadecimal
  • Data Types
  • Whole Number Data Types
  • Floating-Point Data Types
  • Text Data Types
  • The bool Data Type
  • Project: Determining the Size of Data Types
  • The sizeof Operator
  • Changing the Source File of Your Project
  • Code and Output
  • Expressions
  • Outputting an Expression
  • Escape Sequences
  • Quiz
  • Chapter 3 Variables
  • Declaring Variables
  • Syntax of Declaring Variables
  • Declaring Multiple Variables of the Same Data Type
  • Naming the Variable
  • Naming Conventions
  • The Address Operator
  • Using the Address and size of Operators with Variables
  • Assigning Values to Variables
  • Assignment Operator
  • Using the cin Object
  • Quiz
  • Chapter 4 Arithmetic Operators
  • Arithmetic Operators
  • The Addition Operator
  • The Subtraction Operator
  • The Multiplication Operator
  • Division Operators
  • Exponents
  • The Change Machine Project
  • Program Description
  • The Code
  • The Algorithm
  • Quiz
  • Chapter 5 Making Decisions: if and switch Statements
  • Relational Operators
  • Relational Expressions
  • Precedence
  • Flowcharting
  • The if Statement
  • Indenting
  • Common Mistakes
  • The if / else Statement
  • Conditional Operator
  • Common Mistakes
  • The if /else if /else Statement
  • The switch Statement
  • Differences Between switch and if /else if /else Statements
  • Quiz
  • Chapter 6 Nested if Statements and Logical Operators
  • Nested if Statements
  • Testing if Both Boolean Expressions Are True
  • Testing if Either Boolean Expression Is True
  • Logical Operators
  • The && Operator
  • The || Operator
  • The ! Operator
  • Precedence
  • Using the switch Statement with Logical Operators
  • Quiz
  • Chapter 7 The For Loop
  • Increment and Decrement Operators
  • The Increment Operator
  • The Decrement Operator
  • The Difference Between Prefix and Postfix
  • The For Loop
  • The Syntax of the For Loop
  • Beware the Infinite Loop
  • A Factorial Example
  • Breaking Out of a Loop
  • The Continue Keyword
  • Nesting For Loops
  • Quiz
  • Chapter 8 While and Do While Loops
  • The While Loop
  • Comparison of for and while Loops
  • Using the break Keyword
  • Flags
  • While (true)
  • The continue Keyword
  • Nesting While Loops
  • The Do While Loop
  • Syntax
  • A Do While Loop Example
  • Comparison of the Do While and While Loop
  • Scope
  • Quiz
  • Chapter 9 Functions
  • Defining and Calling a Function
  • Terminology of a Function
  • Defining a Function
  • Calling a Function
  • Prototyping
  • Variable Scope and Lifetime
  • Local Variables
  • Global Variables
  • Static Local Variables
  • Sending Information to a Function
  • Passing Arguments by Value
  • Passing Arguments by Reference
  • Returning a Value from a Function
  • Quiz
  • Chapter 10 Arrays
  • Declaring an Array
  • Constants
  • Array Index
  • Initialization
  • Explicit Array Sizing
  • Implicit Array Sizing
  • Initializing a Character Array
  • Constant Arrays
  • When to Use Initialization
  • Assigning and Displaying Array Values
  • Using the cin and cout Objects with Arrays
  • The cin Object's getline Function
  • Passing Arrays as Function Arguments
  • Quiz
  • Chapter 11 What's the Address? Pointers
  • Declaring a Pointer
  • Syntax of a Pointer Declaration
  • The Meaning of Pointer Data Types
  • Assigning a Value to a Pointer
  • Why You Should Not Try to Use an Unassigned Pointer
  • Null Pointers
  • Assigning a Pointer the Address of a Variable or Constant
  • Indirection Operator and Dereferencing
  • The Pointer as a Variable or a Constant
  • Pointer as a Variable
  • The Array Name as a Constant Pointer
  • Pointer Arithmetic
  • Using a Variable Pointer to Point to an Array
  • Incrementing a Pointer
  • Comparing Addresses
  • Decrementing a Pointer
  • Pointers as Function Arguments
  • Passing an Array Using Pointer Notation
  • Passing a Single Variable Using Pointer Notation
  • Dynamic Memory Allocation
  • Returning Pointers from Functions
  • Returning a Pointer to a Local Variable (Not a Good Idea)
  • Returning a Pointer to a Static Local Variable
  • Returning a Pointer to a Dynamically Created Variable
  • Quiz
  • Chapter 12 Character, C-String, and C++ String Class Functions
  • Reading a Character
  • The "Press Any Key to Continue" Problem
  • Combining Use of cin, cin.get, and cin.getline
  • Rules to Live By
  • Useful Character Functions
  • Case Conversion Functions
  • Functions that Check the Value of a Character
  • Useful C-String and C++ String Functions
  • Determining the Length of a String
  • Assigning a Value to a String
  • Appending to a String
  • Comparing Two Strings
  • Conversion Between a C-String and a Number
  • Quiz
  • Chapter 13 Persistent Data: File Input and Output
  • Text vs. Binary Files
  • The fstream Standard Library
  • The File Access Life Cycle
  • Opening a File
  • Opening a File for Writing
  • Opening a File for Reading
  • Opening a File for Reading and Writing
  • Checking if the File Was Opened
  • Closing a File
  • Writing to a File
  • Reading from a File
  • Reading a Line of a File
  • Looping Through the File
  • File Stream Objects as Function Arguments
  • Quiz
  • Chapter 14 The Road Ahead: Structures and Classes
  • Your Reasons for Reading This Book?
  • Object-Oriented Programming
  • Structures
  • Declaring a Structure
  • Declaring a Structure Variable
  • Accessing Structure Member Variables
  • Initializing a Structure
  • Passing Structures as Function Arguments
  • Nesting Structures
  • Classes
  • Quiz
  • Final Exam
  • Answers to Quizzes and Final Exam
  • Index