- Lecture 1: Introduction to C++
- Lecture 2: Data Types Variables & Type Casting
- Lecture 3: Branching
- Lecture 4: Looping
- Lecture 5: Functions I
- Lecture 6: Functions II
- Lecture 7: File I/O I
- Test 1: Lectures 1-7
- Lecture 8: File I/O II
- Lecture 9: Code Style and Documentation
- Lecture 10: Namespaces
- Lecture 11: Problem Solving in C++ I (Connect 4)
- Lecture 12: Problem Solving in C++ II (Connect 4)
- Lecture 13: Pointers in C++ I
- Lecture 14: Pointers in C++ II
- Test 2: Lectures 1-14 (emphasis on 8-14) – Monday, November 9, 2020
- Lecture 15: Dynamic Variables
- Lecture 16: Dynamic Arrays
- Lecture 17: Classes in C++ I
- Lecture 18: Classes in C++ II
- Lecture 19: Implementing a Stack in C++
- Lecture 20: Implementing a Linked List in C++ I
- Lecture 21: Implementing a Linked List in C++ II
- Test 3: Lectures 1-21 (emphasis on 15-21) – Monday, December 7, 2020
Lecture 1: Introduction to C++
- A first introduction to programming in C++. We will learn how to compile and run C++ programs from the command-line in Linux.
- Slides: [PDF]
- Video: No video available
- Exercises:
- helloclass.cpp – a first C++ program.
- References:
LECTURE 2: Data Types, Variables & Type Casting
- Today we will learn the basics of writing C++ programs including input/output, data types and variables and type casting.
- Slides: [PDF]
- Video: [Google Drive]
- Exercises:
- hello_string.cpp – example of C++ input and output using a string.
- hello_double.cpp – example of formatting double output. [YouTube]
- type_casting_ex1.cpp – an extension of the hello_double example to show type casting.
- char_to_int.cpp – a program that converts an ASCII character into an integer.
LECTURE 3: BRANCHING
- Today we will learn about branching in C++ including if statements and switch statements.
- Slides: [PDF]
- Video: [Google Drive]
- Exercises:
- int_swap.cpp – in-class challenge problem to swap two integers without using a third temporary variable.
- branching_ex1.cpp – if statement example with optional else if and else clauses.
- branching_ex2.cpp – switch statement example.
LECTURE 4: LOOPING
- Today we will learn about looping in C++ including for loops, while loops and do-while loops.
- Slides: [PDF]
- Video: [Google Drive]
- Exercises:
- loop_ex1.cpp – three different for loop examples for adding up even numbers.
- loop_ex2.cpp – a while loop example for adding up even numbers.
- loop_ex3.cpp – a while loop example for finding the largest positive number less than 200,000 and divisible by 63.
- loop_ex4.cpp – a do-while loop example for summing positive numbers until a zero or negative number is entered by the user.
LECTURE 5: FUNCTIONS I
- We will learn how to use predefined functions in libraries such as cmath and ctime. In addition to using predefined functions we can also create our own functions and use them in our programs. We will also start to learn about overloading functions.
- Slides: [PDF]
- Video: [Google Drive]
- Exercises:
- predefined_function_ex1.cpp – using predefined functions from cmath in your programs. [YouTube]
- predefined_function_ex2.cpp – using predefined functions to create random student numbers. [YouTube]
- programmer_function_ex1.cpp – creating a programmer defined function. [YouTube]
- programmer_function_ex1b.cpp – overloading functions. [YouTube]
LECTURE 6: FUNCTIONS II
- Today, we will continue to learn about programmer-defined functions topics including the difference between call-by-value and call-by-reference parameters.
- Slides: none
- Video: [Google Drive]
- Exercises:
- programmer_function_ex1c.cpp – overloading functions.
- programmer_function_ex2.cpp, programmer_function_ex2b.cpp – call-by-value vs. call-by-reference parameters vs. const call-by-reference parameters [YouTube]
LECTURE 7: FILE INPUT/OUTPUT I
- Today we’ll learn about file input and output using streams. How to write to files, read from a file and append to a file. Our file input and output example will also introduce arrays. Although arrays are not the main topic of the lecture they are an important programming language concept. Next, we’ll learn how to handle when a file fails to open. To assist with the example we will learn about the the chmod Linux command.
- Video: [Google Drive]
- Exercises:
- fileio_ex1.cpp – writing to a file and reading from a file. [YouTube]
Test 1: Lectures 1-7
- Test Review Video: [Google Drive]
LECTURE 8: FILE INPUT/OUTPUT II
- Today we’ll learn more about file input and output using streams including how to append to a file. Next, we’ll learn how to handle when a file fails to open. To assist with the example we will learn about the the chmod Linux command.
- Notes: [chmod.txt]
- Video: [Google Drive]
- Exercises:
- fileio_ex2.cpp – appending to a file. [YouTube]
- fileio_ex3.cpp – example of handling file access issues/errors during reading and writing.
- References:
LECTURE 9: CODE STYLE & DOCUMENTATION
- Overview of how to properly document your programs including in-program documentation and API documentation. We will also learn about code style – best practices for how to write and organize your programs. Examples of code style include best practices for indentation, white space, line length, comments, naming conventions and file structure.
- Slides: [PDF]
- Video: [Google Drive]
- References:
LECTURE 10: NAMESPACES
- Overview of the four kinds of namespaces in C++: the standard namespace, user-defined namespaces, the unnamed namespace and the global namespace.
- Video: [Google Drive]
- Slides: [PDF]
- Exercises:
- namespace_ex1.cpp – examples of using the standard namespace, user-defined namespaces and unnamed namespace as well as an examples of using the scope resolution operator (::) with namespaces.
LECTURE 11: PROBLEM SOLVING IN C++ I (CONNECT 4)
- Today we’ll build on the C++ concepts that we’ve covered in Lectures 1-10 and put them all together to program Connect 4.
- Video: [Google Drive]
- Exercises:
- connect4_v1.cpp – the first version of our Connect 4 game.
LECTURE 12: PROBLEM SOLVING IN C++ II (CONNECT 4)
- Today we’ll continue to build on the C++ concepts that we’ve covered in Lectures 1-10 and put them all together to program Connect 4.
- Video: [Google Drive]
- Exercises:
- connect4_v2.cpp – the second version of our Connect 4 game.
LECTURE 13: POINTERS IN C++ I
- Introduction to pointers, declaring a pointer variable, the dereferencing operator and the address-of operator.
- Video: [Google Drive]
- Slides: [PDF]
LECTURE 14: POINTERS IN C++ II
- More pointers and defining pointer types.
- Video: [Google Drive]
- Slides: [PDF]
- Exercises:
- pointers_ex1.cpp – an example of using pointers with ordinary (automatic) variables in C++. [YouTube]
- pointers_ex2.cpp, pointers_ex3.cpp – an example of how to pass a pointer variable to a function as a call-by-value parameter. This is the first of two examples that highlight the difference between passing a pointer as a call-by-value vs. call-by-reference parameter. [YouTube & YouTube]
Test 2: Lectures 1-14 (emphasis on 8-14)
- Test Review Video: [Google Drive]
LECTURE 15: DYNAMIC VARIABLES
- Using pointers to create dynamic variables and dynamic arrays.
- Video: [Google Drive]
- Slides: [PDF]
- Jamboard:
- Dynamic variable example:
- Dynamic variable example:
- Exercises:
- dynamic_variable.cpp – creating and deleting a dynamic variable
- dynamic_array.cpp – creating and deleting a dynamic array
LECTURE 16: DYNAMIC ARRAYS
- More examples of dynamic arrays.
- Video: [Google Drive]
- Slides: [PDF]
- Exercises:
- dynamic_array_ex2.cpp – using a dynamic array to input an unknown number of integers from a user
- dynamic_array_ex3.cpp – using an integer pointer to return a dynamic array from a function
- 2d_dynamic_array.cpp – an example of creating and destroying a 2D dynamic array of integers.
LECTURE 17: CLASSES IN C++ I
- An introduction to structures and classes in C++. We will learn about member variables, member functions including constructors, destructors, accessor and mutator functions.
- Video: [Google Drive]
- Slides: [PDF]
- Exercises:
- struct_ex.cpp – an example of a Person composite data type [YouTube]
- class_ex1.cpp – an example of a Person class [YouTube] [YouTube]
LECTURE 18: CLASSES IN C++ II
- More on classes in C++ including friend functions and overloading operators.
- Video: [Google Drive]
- Slides: [PDF]
- Exercises:
- class_ex2.cpp – friend functions in a Person class
- class_ex3.cpp – overloading operators (==, <<) in a Person class [YouTube]
LECTURE 19: Implementing A STACK in C++
- Implementing a Stack class in C++ using pointers.
- Video: [Google Drive]
- Jamboard:
- Data structures:
- Data structures:
- Exercises:
- stack.cpp – a Stack class with a constructor, deconstructor, pop function, push function, isEmpty function and toString function
LECTURE 20: Implementing A Linked List in C++
- Implementing a Linked List class in C++ using pointers.
- Video: [Google Drive]
- Jamboard:
- Linked list overview:
- Linked list overview:
- Exercises:
- linked_list.cpp – a Linked List class with a constructor, deconstructor, addFront function, addBack function and isEmpty function.
LECTURE 21: Implementing A Linked List in C++ II
- Continuing to implement a Linked List class in C++ using pointers.
- Video: [Google Drive]
- Exercises:
- linked_list_ex2.cpp – a Linked List class with a constructor, deconstructor, addFront function, addBack function, isEmpty function as well as a remove function, a displayList function and an operator= overloaded function.
Test 3: Lectures 1-21 (emphasis on 15-21)
- Test Review Video: [Google Drive]