About Object Oriented Programming Using C++
Object Oriented Programming using C++ teaches a new way of thinking about programs. Instead of writing a list of functions that work on data, you model a problem as objects that hold their own data and behaviour. The ideas you learn here (classes, inheritance, polymorphism) are the same ideas used in Java, Python and almost every modern language, so this subject pays off well beyond C++.
What the units cover
- Introduction: procedural versus object-oriented programming, the basic concepts of objects, classes, abstraction, encapsulation and data hiding, and how C++ differs from C.
- Classes and objects: defining classes, access specifiers, member functions, constructors and destructors, static members, and friend functions.
- Inheritance and polymorphism: single, multiple, multilevel and hierarchical inheritance, constructors in derived classes, function and operator overloading, function overriding and virtual functions.
- Generic functions: function templates and class templates.
- Files and exception handling: reading and writing files with streams, and handling errors with try, catch and throw.
What the exam looks like
The Dec 2017 and Dec 2018 papers on this page both followed the 75-mark pattern: five 3-mark questions, two out of three 7½-mark questions, and three out of five 15-mark questions. Short questions asked you to define class, object, abstraction, data hiding and aggregation, or to explain call by value versus call by reference. The longer questions asked for programs: overloading the + operator and the unary operators, showing how constructors work with inheritance, using friend functions, demonstrating polymorphism, and showing exception handling. Operator overloading versus overriding appeared in both years.
How to study it
Write code for every concept. Keep a small set of example programs, such as a Student class, a Complex class with an overloaded + operator, and a base and derived class with constructors, and make sure you can write each one from memory. In the exam, a short correct program with a line of explanation scores better than long theory.
Topics worth practising
- Constructors and destructors, including constructors in inheritance
- Types of inheritance with sample programs
- Overloading binary and unary operators
- Operator overloading versus overriding
- Friend functions
- Exception handling with try, catch and throw
- Templates (generic functions and classes)
Use the notes on this page for each unit and practise with the previous year papers.
