An Animated Introduction to Programming in C++

Mark Mahoney

Welcome! This book is an introduction to programming using C++. I assume the reader has no previous programming experience. My goal is to focus on worked coding examples to explain how to program. Most of what I write will be in the context of a code example. The code will always be the priority but I have also added text, pictures, screenshots, and videos that refer to the code.

The tool that I am using to show these examples is called Storyteller. It animates the construction of some code that a software developer has written. I will use it to show how a program grows from an empty file to a functioning program. I will explain the basics of C++ programming by telling the story of how programs grow. For each of the 'playbacks' below simply click on the comments on the left hand side of the screen to move through the code.

If you'd like to stay connected and get updates when I add new playbacks you can follow me on twitter: @markm208.

1.1 Name printer program
1.2 Distance formula
1.3 Basic types in C++
1.4 Number types
1.5 Characters and strings
1.6 Weekly pay calculator
1.7 Distance formula revisited
1.8 Gas Mileage
2.1 Booleans
2.2 Even/odd calculator
2.3 Overtime pay with an if/else
2.4 Water temperature
2.5 Switch
3.1 A simple loop
3.2 More loops
3.3 Summation
3.4 Nested loop
3.5 for loop
3.6 Capitalization
3.7 break and continue
4.1 Arrays
4.2 Average and standard deviation of an array of values
4.3 Problems with arrays
4.4 Flipping coins
4.5 Multi-dimensional arrays
5.1 Functions
5.2 Value returning functions
5.3 Functions with parameters
5.4 Passing parameters by reference
5.5 The scope of variables
5.6 Prime number function
5.7 Passing arrays to functions
6.1 vector
6.2 Passing a vector to a function
6.3 Advanced features of vectors
6.4 Reading from a file and storing in a vector
6.5 Linear search and binary search
6.6 Bubble sort
6.7 Writing to a file
6.8 Two dimensional vectors
7.1 Simple struct
7.2 Hierarchical structs
7.3 Vectors as members of structs
7.4 structs with a vector of objects
7.5 Calculus with structs
8.1 Simple pointers
8.2 Pointer to an object
8.3 Vectors of pointers
8.4 Arrays are pointers
8.5 Passing data to functions with pointers
8.6 Comparing pointers
8.7 Three types of variables- global, local, and dynamic
8.8 Dynamic variables example
8.9 Dangling pointers and null pointers
8.10 Dynamic array of students
8.11 Function Pointers
9.1 Simple class
9.2 A class with data members
9.3 A class with objects for data members
9.4 Common word analysis
9.5 Student and course registration system
9.6 Inheritance and polymorphism
9.7 Shape inheritance hierarchy
9.8 Inheritance and polymorphism in C++
9.9 Copy Constructor Example
10.1 Simple linked list
10.2 Simple hash table
10.3 More complex hash table
10.4 STL unordered_map
10.5 Binary search tree
10.6 Graph adjacency matrix
11.1 The C++ SQLite API
11.2 An Object Oriented Auction Program with SQLite
11.3 SQLite Transactions
12.1 Automated Testing
12.2 Simple Image Example
12.3 Neural Networks