Programming in C++
Frank Vahid | Roman Lysecky
zyBooks 2017

Table of Contents

1. Introduction to C++
1.1 Programming
1.2 A first program
1.3 Basic output
1.4 Basic input
1.5 Comments and whitespace
1.6 Errors and warnings
1.7 Computers and programs
1.8 Computer tour
1.9 Language history
1.10 Problem solving
1.11 C++ example: Salary Calculation
1.12 C++ example: Married-couple names

2. Variables / Assignments
2.1 Variables (int)
2.2 Assignments
2.3 Identifiers
2.4 Arithmetic expressions (int)
2.5 Floating-point numbers (double)
2.6 Constant variables
2.7 Using math functions
2.8 Type conversions
2.9 Binary
2.10 Characters
2.11 String basics
2.12 Integer overflow
2.13 Numeric data types
2.14 Unsigned
2.15 Random numbers
2.16 Debugging
2.17 Auto (since C++11)
2.18 Style guidelines
2.19 C++ example: Salary calculation with variables
2.20 C++ example: Married-couple names with variables

3. Branches
3.1 If-else
3.2 Relational and equality operators
3.3 Multiple if-else branches
3.4 Logical operators
3.5 Switch statements
3.6 Boolean data types
3.7 String comparisons
3.8 String access operations
3.9 String modify operations
3.10 Character operations
3.11 Conditional expressions
3.12 Floating-point comparison
3.13 Short circuit evaluation
3.14 C++ example: Salary calculation with branches
3.15 C++ example: Search for name using branches

4. Loops
4.1 Loops
4.2 While loops
4.3 More while examples
4.4 Counting
4.5 For loops
4.6 Nested loops
4.7 Developing programs incrementally
4.8 Break and continue
4.9 Variable name scope
4.10 Enumerations
4.11 C++ example: Salary calculation with loops
4.12 C++ example: Domain name validation with loops

5. Arrays / Vectors
5.1 Array/vector concept
5.2 Vectors
5.3 Array/vector iteration drill
5.4 Iterating through vectors
5.5 Multiple vectors
5.6 Vector resize
5.7 Vector push_back
5.8 Loop-modifying or copying/comparing vectors
5.9 Swapping two variables
5.10 Debugging example: Reversing a vector
5.11 Arrays vs. vectors
5.12 Two-dimensional arrays
5.13 Char arrays / C strings
5.14 String library functions
5.15 Char library functions: ctype
5.16 C++ example: Salary calculation with vectors
5.17 C++ example: Domain name validation with vectors

6. User-Defined Functions
6.1 User-defined function basics
6.2 Parameters
6.3 Return
6.4 Reasons for defining functions
6.5 Functions with branches/loops
6.6 Unit testing (functions)
6.7 How functions work
6.8 Functions: Common errors
6.9 Pass by reference
6.10 Functions with string/vector parameters
6.11 Functions with C string parameters
6.12 Scope of variable/function definitions
6.13 Default parameter values
6.14 Function name overloading
6.15 Preprocessor and include
6.16 Separate files
6.17 C++ example: Salary calculation with functions
6.18 C++ example: Domain name validation with functions

7. Objects and Classes
7.1 Objects: Introduction
7.2 Classes: Introduction
7.3 Classes example (with vectors)
7.4 Mutators, accessors, and private helpers
7.5 Constructors
7.6 Constructor overloading
7.7 Constructors: Member initialization
7.8 Unit testing (classes)
7.9 The ‘this’ implicit parameter
7.10 Operator overloading
7.11 Abstract data types: Introduction
7.12 Vector ADT
7.13 Namespaces
7.14 Separate files for classes
7.15 Classes with classes
7.16 C++ example: Salary calculation with classes
7.17 C++ example: Domain name availability with classes

8. Pointers
8.1 Why pointers: A list example
8.2 Pointer basics
8.3 Operators: new, delete, and ->
8.4 String functions with pointers
8.5 A first linked list
8.6 Memory regions: Heap/Stack
8.7 Miscellaneous pointer issues
8.8 Memory leaks
8.9 Destructors
8.10 Copy constructors
8.11 Copy assignment operator
8.12 Rule of three
8.13 C++ example: Employee list using vectors

9. Streams
9.1 The ostream and cout streams
9.2 The istream and cin streams
9.3 Output formatting
9.4 String streams
9.5 File input and output
9.6 Stream errors
9.7 Extraction before getline

10. Inheritance
10.1 Derived classes
10.2 Access by members of derived classes
10.3 Overriding member functions
10.4 Polymorphism and virtual member functions
10.5 Is-a versus has-a relationships
10.6 C++ example: Employees and overriding class functions
10.7 C++ example: Employees using an abstract class

11. Recursion
11.1 Recursion: Introduction
11.2 Recursive functions
11.3 Recursive algorithm: Search
11.4 Adding output statements for debugging
11.5 Creating a recursive function
11.6 Recursive math functions
11.7 Recursive exploration of all possibilities
11.8 Stack overflow
11.9 C++ example: Recursively output permutations

12. Exceptions
12.1 Exception basics
12.2 Exceptions with functions
12.3 Multiple handlers
12.4 C++ example: Generate number format exception

13. Templates
13.1 Function templates
13.2 Class templates
13.3 C++ example: Map values using a function template

14. Additional Material
14.1 Do-while loops
14.2 Arrays
14.3 Iterating through arrays
14.4 Multiple arrays
14.5 Loop-modifying or copying/comparing arrays
14.6 Debugging example: Reversing an array
14.7 Engineering examples
14.8 Functions with array parameters
14.9 Functions with array parameters: Common errors
14.10 Engineering examples using functions
14.11 Grouping data: struct
14.12 Structs and functions
14.13 Structs and vectors
14.14 Structs, vectors, and functions: A seat reservation example
14.15 Command-line arguments
14.16 Command-line arguments and files
14.17 The #define directive
14.18 Modular compilation
14.19 Makefiles
14.20 Additional practice: Output art
14.21 Additional practice: Grade calculation
14.22 Additional practice: Health data
14.23 Additional practice: Tweet decoder
14.24 Additional practice: Dice statistics
14.25 zyBooks built-in programming window