Lectures

Lecture 1: Introduction to C++

LECTURE 2: Data Types & Variables

  • Today we will learn the basics of writing C++ programs including input/output, data types and variables and type casting.
  • Slides: [PDF]
  • Exercises:
  •  Readings:
    • Absolute C++ 6/E 1.2-1.5

LECTURE 3: Type Casting

  • Today we will learn more about the basics of writing C++ programs including data types and type casting.
  • Slides: [PDF] (same as Lecture 2)
  • Exercises:
  •  Readings:
    • Absolute C++ 6/E 1.2-1.5

LECTURE 4: BRANCHING

  • Today we will learn about branching in C++ including if statements and switch statements.
  • Slides: [PDF]
  • Exercises:
  • Readings:
    • Absolute C++ 6/E 2.1-2.2

LECTURE 5: LOOPING

  • Today we will learn about looping in C++ including for loops, while loops and do-while loops.
  • Exercises:
    • loop_ex1.cpp – two different for loop examples for adding up even numbers.
    • loop_ex2.cpp – while loop example for adding up even numbers.
    • loop_ex3.cpp – while loop example for finding the largest number less than 10,000,000 and divisible by 63.
    • loop_ex4.cpp – while loop example for allowing user to enter an arbitrary amount of input.
  • Readings:
    • Absolute C++ 6/E 2.3

Lecture 6: 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 programmer-defined functions.
  • Exercises:
  • Readings:
    • Absolute C++ 6/E 3.1, 3.2, 3.3, 4.1, 4.2

Lecture 7: Functions II

LECTURE 8: FILE INPUT/OUTPUT

  • 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.
  • Exercises:
  • Readings:
    • Absolute C++ 6/E 12.1, 12.2, 5.1-5.3
  • References:

LECTURE 9: Namespaces

  • Overview of the four kinds of namespaces in C++: the standard namespace, user-defined namespaces, the unnamed namespace and the global namespace.
  • 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 10: 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]
  • Readings:
    • Absolute C++ 6/E 1.4
  • References:

TEST #1: LECTURES 1-9

  • Our first test will take place in class on Friday, October 19, 2018 and will cover Lectures 1-9 inclusive. The test will be approximately 60% written (short answer, true/false, etc.) and 40% programming (using your laptop). You will not have access to any course materials or online resources for the test as it will be closed book.

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.
  • Blackboard:
    • Planning for our Connect 4 game: Connect 4 Planning

LECTURE 12: PROBLEM SOLVING IN C++ II – 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.
  • Exercises:

LECTURE 13: PROBLEM SOLVING IN C++ III – 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.
  • Exercises:

LECTURE 14: POINTERS IN C++ I

  • Introduction to pointers, declaring a pointer variable, the dereferencing operator and the address-of operator.
  • Slides: [PDF]
  • Blackboard:
    • Pointers example from slide 6:Pointers example from blackboard
  • Readings:
    • Absolute C++ 6/E 10.1

LECTURE 15: POINTERS IN C++ II

  • More pointers and defining pointer types.
  • Slides: [PDF]
  • Exercises:
    • pointers_ex1.cpp – an example of using pointers with ordinary (automatic) variables in C++.  [YouTube]
    • pointers_ex2.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]

LECTURE 16: DYNAMIC VARIABLES

  • Using pointers to create dynamic variables and dynamic arrays.
  • Slides: [PDF]
  • Blackboard:
    • Dynamic variable example:Dynamic Variable example
  • Exercises:

LECTURE 17: DYNAMIC ARRAYS

  • More examples of dynamic arrays.
  • Slides: [PDF]
  • Exercises:
  • Readings:
    • Absolute C++ 6/E 10.2

LECTURE 18: CLASSES IN C++ I

  • An introduction to structures and classes in C++. We will learn about member variables, member functions including constructors.
  • Slides: [PDF]
  • Exercises:
  • Readings:
    • Absolute C++ 6/E 6.1, 6.2, 7.1

LECTURE 19: CLASSES IN C++ II

  • More on classes in C++ including accessor and mutator functions and overloading operators.
  • Slides: [PDF]
  • Exercises:
  • Readings:
    • Absolute C++ 6/E 6.2, 8.1

LECTURE 20: A STACK CLASS

  • Implementing a Stack class in C++ using pointers.
  • Exercises:
    • stack.cpp – a Stack class with a constructor, deconstructor, pop function, push function, isEmpty function and toString function [YouTube]

TEST #2: LECTURES 10, 14-20

  • Our second test will take place in class on Friday, November 30, 2018 and will cover Lecture 10 and Lectures 14-20 inclusive. The test will be approximately 50% written (short answer, true/false, etc.) and 50% programming (using your laptop). You will not have access to any course materials or online resources for the test as it will be closed book.

LECTURE 21: CLASSES IN C++ III

  • Friend functions and more overloading operators in C++ classes.
  • Slides: [PDF]
  • Exercises:
  • Readings:
    • Absolute C++ 8.1, 8.2, 8.3