Object-Oriented Programming
Course Overview
Welcome! This course takes the C++ you already know and builds on it with classes and objects. Over eight weeks you will learn how to group data and the functions that work on it, how to manage memory, how to reuse code through inheritance, and how to make your own types behave like the built-in ones. In short, this course is where you stop writing programs as a list of functions and start designing them as a set of cooperating objects.
Prerequisites
The Structured Programming course. Week 1 revises the parts you need: basic statements, variables, conditionals, loops, functions, pointers, function overloading and arrays. If something there feels new, go back to the Structured Programming notes before moving on.
Textbook
We will use the following textbook. We will also use slides, notes, and other resources as necessary.

References

Course Topics
The first week revises the Structured Programming material. The next four weeks cover classes: how to build them, create and destroy objects, protect data, and manage memory. The last three weeks cover how classes relate to each other and how to make them easy to use: inheritance, polymorphism and operator overloading.
| Week | Topic |
|---|---|
| 1 | Revision: functions, pointers, arrays |
| 2 | Classes I: constructors, destructors, set and get functions |
| 3 | Classes I: object parameters, interface vs implementation, arrays of objects |
| 4 | Classes II: const, static, composition |
| 5 | Classes II: dynamic memory, this, friend functions and classes |
| 6 | Inheritance |
| 7 | Polymorphism |
| 8 | Operator overloading |
Here is what you should expect to achieve by the end of the course:
- Be able to design and implement classes with constructors, destructors, and properly protected data.
- Be able to manage memory correctly, using dynamic allocation, deep copies and destructors.
- Be able to reuse and extend code through composition, inheritance and polymorphism.
- Be able to write natural, readable code by overloading operators for your own classes.
Tools

We will learn object-oriented programming in C++!

This is the IDE (Integrated Development Environment) you will use for programming in C++. While you are allowed to use other IDEs, this is the one we will use in the classroom and provide support for. [download] [Installation Guide]
Frequently Asked Questions
Studying for this course
How do you suggest I study for this course?
Make sure that you do the following every week:- Read the lectures (from the Course Notes page) and make sure you understand them. Go to office hours and ask questions if you have difficulty understanding something.
- Type and run every example yourself. Do not only read the code. Change it, break it, and see what happens.
- Solve the weekly worksheet over the weekend, then at the beginning of the following week resolve any issues you faced.
I forgot a lot from Structured Programming. Am I going to be lost?
No. That is exactly why Week 1 is a revision. Go through it slowly, and if a topic still feels weak, use the Structured Programming notes. Pointers and functions matter the most, because Weeks 5 to 7 build on them.I already know a lot of programming. This course is too easy for me.
Great! This is good news, not bad news. This means that you can get good grades in the course and work more on improving your skills in programming. Here are a few notes.- Check the Resources page. There are exercises there to improve your skills.
- Help others. Students might ask questions on social media groups. Your expertise is needed in answering student questions.
- Be respectful of others. It can be easy to (unintentionally) put others off by making them feel inferior. Be conscious about how you answer and ask questions during lectures, or when students seek your help!
I understand the lectures and examples, but I struggle to write my own classes.
Understanding a class someone else wrote is very different from designing one from scratch. Here is how to bridge that gap:- Start from the main function: Write the code you wish you could write (
Date d(7, 10, 2023); d.print();), then build the class that makes it work. - Trace with pen and paper: Draw each object as a box with its data members, and follow the program line by line, especially for constructors and destructors.
- Embrace the Struggle: Getting stuck on a new question is the most important part of learning. Don't rush to the answer key immediately.