Lecture 1: Course overview and the Object-Oriented (OO) model
- Introduces the course (object-oriented model, classes, inheritance, polymorphism, etc.) and how the course will be graded.
- Explains what a “model” is (an abstraction used to understand a system before building it) and why abstraction matters.
- Defines an object using three key ideas: state (attributes), behavior (operations/methods), and identity (what makes it uniquely itself).
|
Download PDF |
Lecture 2: Abstraction, classes, and user-defined data types in C++
- Revisits abstraction and emphasizes: “capture only the details relevant to the current perspective,” to manage complexity.
- Introduces classes (grouping objects with the same structure/behavior) and shows simple class representations (state + behavior).
- Moves into C++ “user-defined data types” like typedef and struct, including how to create/use structures and basic memory ideas (e.g., dynamic allocation).
|
Download PDF |
Lecture 3: C++ classes: access control, member functions, constructors, and overloading
- Explains how to design classes in C++ using private/protected/public access specifiers and class definitions.
- Shows how to write member functions inside/outside the class using the scope resolution operator (::) and introduces inline functions.
- Introduces constructors (including default constructors) and connects the idea of function overloading to constructor overloading.
|
Download PDF |
Lecture 4: Copy constructors, shallow vs deep copy, and the this pointer
- Explains when a copy constructor is called (e.g., object creation from another object, passing by value).
- Compares shallow copy vs deep copy, especially when objects contain pointer/reference-type members.
- Introduces the this pointer and why it’s needed (member functions must know which object instance they are operating on).
|
Download PDF |
Lecture 5: Separating interface vs implementation, and const member functions
- Defines a class’s interface (public methods) and argues for keeping interface separate from implementation (header .h vs source .cpp).
- Demonstrates the common multi-file C++ structure (e.g., Rectangle.h, Rectangle.cpp, main.cpp).
- Introduces const member functions to enforce “read-only” behavior and catch accidental state changes at compile time.
|
Download PDF |
Lecture 6: Member initializer lists, constant data members, and constant objects
- Shows why const data members must be initialized using a member initializer list (not assigned inside the constructor body).
- Explains the order of initialization rule: members initialize in the order they are declared in the class (not the order listed).
- Covers const objects and the rule that they can only call const member functions, encouraging safer class design.
|
Download PDF |
Lecture 7: Static variables, static data members, and static member functions
- Explains static local variables: initialized once, keep their value across calls, and live for the entire program lifetime.
- Introduces static data members (class variables) shared across all objects, defined outside the class, and accessible via ClassName::member.
- Shows typical uses like tracking the number of objects created, and introduces static member functions (which can’t access non-static members).
|
Download PDF |
Lecture 8: Arrays of objects, pointers to objects, and a Date-class case study
- Explains why arrays of objects generally require a default constructor (or an explicit initializer list for each element).
- Covers pointers to objects and how object pointers use -> to call member functions and can support dynamic allocation patterns.
- Applies concepts in a case study: designing a Date class with day/month/year plus a static shared “ExamDate,” and defining its interfaces/files.
|
Download PDF |
Lecture 9: Composition vs aggregation (object reuse with lifetime rules)
- Frames OOP as “code reuse,” including using an object of one class inside another.
- Distinguishes composition (strong “owns-a” relationship: part’s lifetime depends on the whole) from aggregation (weak “has-a” relationship: the part can outlive the whole).
- Connects the idea to C++ design: composition often uses a direct member object, while aggregation often uses a pointer/reference to a borrowed object.
|
Download PDF |
Lecture 10: Friend functions and friend classes
- Explains the access problem: private/protected members normally can’t be accessed outside the class—except by friends.
- Shows how to declare friend functions and friend classes so external code can access internal members when necessary.
- Emphasizes caution: “friend” weakens encapsulation, so it should be used only when there’s no cleaner alternative.
|
Download PDF |
Lecture 11: Operator Overloading Fundamentals
- Explains what operators are (unary vs. binary) and what “operator overloading” means for classes (user-defined types).
- Shows why overloading is useful: it lets operators like +, -, <, > work naturally with your own class objects instead of messy function calls.
- Lays out the key rules/limits: you can’t change operator precedence/associativity, and you can’t invent brand-new operators.
|
Download PDF |
Lecture 12: Overloading the Assignment Operator (=) for Safe Copying
- Focuses on what happens when you do bar = foo, including “member-wise copy” and why it can be dangerous with pointers.
- Demonstrates how dynamic memory (e.g., new int) can lead to memory leaks or incorrect sharing if you rely on the default assignment behavior.
- Introduces writing an overloaded operator= (often using references) so assignment copies data correctly and safely for pointer-based objects.
|
Download PDF |
Lecture 13: Stream Insertion/Extraction (<<, >>) Operator Overloading
- Explains that << and >> are used by the iostream library for cout (ostream) and cin (istream), and can be overloaded for your own classes.
- Shows the common pattern of implementing operator << (usually as a friend) so objects can be printed with cout << obj.
- Explains why the function returns ostream & (to allow chaining like cout << a << b) and why references help avoid unnecessary copying.
|
Download PDF |
Lecture 14: Overloading Special and Unary Operators (Including ++ / --)
- Covers overloading “special” operators for classes (like the subscript []) and how they’re used to make objects feel like built-in types.
- Explains how to overload unary operators such as increment/decrement and what behavior you’re trying to model in your class.
- Distinguishes prefix vs postfix forms using different signatures (e.g., operator++() vs operator++(int)) and shows member-function vs friend-function approaches.
|
Download PDF |
Lecture 15: Typecasting and Type Conversion (Built-in and User-defined)
- Defines type conversion and contrasts implicit conversion (done automatically by the compiler) vs explicit conversion (forced by the programmer).
- Explains user-defined conversions: (1) other type → your class via a single-argument constructor, and (2) your class → other type via a conversion operator.
- Shows how explicit prevents unwanted implicit conversions (both for constructors and conversion operators), forcing you to convert deliberately.
|
Download PDF |
Lecture 16: Inheritance Basics and Access Control
- Defines inheritance as extending an existing (base/parent) class into a new (derived/child) class.
- Clarifies what is and isn’t inherited (e.g., not constructors/destructors, not operator=, not private members).
- Explains public/protected/private inheritance and how each affects member accessibility in the derived class.
|
Download PDF |
Lecture 17: Inheritance in Memory and Constructor Order
- Explains that a derived-class object contains an “anonymous” base-class part inside it (base members + derived members).
- Shows constructor order: when you create a derived object, the base-class constructor runs first, then the derived-class constructor.
- Introduces base-class initialization syntax so a derived constructor can explicitly call a specific base constructor (especially when the base has parameters).
|
Download PDF |
Lecture 18: Types of Inheritance in C++
- Lists the major inheritance forms supported (single, multiple, multilevel, hybrid, hierarchical, multipath).
- Explains what each form means conceptually (e.g., “single” = one base class; “multiple” = more than one base class).
- Reinforces the concepts with simple class-diagram style examples showing how classes relate in each inheritance type.
|
Download PDF |
Lecture 19: Overriding vs Overloading (and Using Scope Resolution)
- Defines overriding: a derived class replaces a base-class function by providing the same signature (same name/parameters).
- Contrasts with overloading: happens within one class by changing parameter lists; trying to “duplicate” the same signature is an error.
- Shows how to call the base version with the scope operator (e.g., Parent::myFunction()), and highlights ambiguity problems in multiple/diamond inheritance.
|
Download PDF |
Lecture 20: Copy Constructor and Assignment Operator in Inheritance
- Explains the default behavior: when copying a derived object, the base part is copied first, then the derived part.
- Introduces shallow vs deep copy issues (especially with pointer members) and why you often need custom copy logic.
- Covers assignment operator behavior in inheritance: base assignment first, then derived—plus why you may need to explicitly call the base-class operator= when writing your own.
|
Download PDF |
Lecture 21: Polymorphism with virtual functions (run-time binding)
- Explains polymorphism as “different objects responding differently to the same message,” so the caller doesn’t need to know the exact derived type.
- Compares static (compile-time) binding vs dynamic (run-time) binding, and shows how virtual functions enable run-time binding through base pointers/references.
- Introduces pure virtual functions and abstract classes (interfaces), plus why virtual destructors matter in inheritance hierarchies.
|
Download PDF |
Lecture 22: Generic programming with function templates
- Motivates generic programming: avoid writing the same function many times for different data types (e.g., int vs float comparisons).
- Introduces function templates and how the compiler generates type-specific versions from one template definition.
- Covers explicit type parameterization and template specialization when a general template doesn’t work correctly for certain types (e.g., C-strings).
|
Download PDF |
Lecture 23: Templates with multiple type parameters and user-defined types
- Shows templates that take more than one type parameter (e.g., T and U) and why that’s useful.
- Demonstrates using templates with user-defined classes, as long as the needed operators (like +) exist for that type.
- Explains when to use function overloading vs templates (different operation by type → overload; same operation across types → template).
|
Download PDF |
Lecture 24: Class templates and how to implement them
- Introduces class templates to avoid duplicating near-identical classes (example: complex numbers for float vs double).
- Shows how to create objects from a class template by plugging in a concrete type (built-in or user-defined).
- Covers common pitfalls: defining template member functions outside the class, and using default type parameters.
|
Download PDF |
Lecture 25: Templates with inheritance + intro to the STL
- Explains how templates work with inheritance, friend functions, and static members (each template instantiation gets its own static copy).
- Introduces the Standard Template Library (STL) and its three main parts: containers, iterators, and algorithms.
- Surveys STL container types (sequence vs associative vs adapters) and gives examples like vector/deque/set/map plus iterator-based loops and algorithms like sort.
|
Download PDF |
Lecture 26: Error handling approaches (before exceptions)
- Compares error-handling strategies: abnormal termination, graceful termination, returning error codes, and exception handling as options.
- Demonstrates how division-by-zero can crash a program if not checked, and how “graceful termination” can at least stop safely.
- Shows returning an error code (e.g., true/false) so the program can recover (like re-prompting for valid input) instead of exiting.
|
Download PDF |
Lecture 27: Exception handling in C++ (try/throw/catch)
- Explains why return-code error handling can make code messy (lots of nested checks mixed with core logic).
- Introduces exceptions: put risky code in try, signal problems with throw, and handle them with one or more catch blocks.
- Covers stack unwinding: when an exception is thrown, the program exits scopes safely and local objects are cleaned up as control moves to a handler.
|
Download PDF |
Lecture 28: File handling with fstream
- Introduces file streams: ifstream (read), ofstream (write), fstream (read/write), and common functions like getline, eof, and close.
- Explains file open modes (input/output/append/truncate/binary) and what each mode does.
- Walks through examples of writing records to a file and then reading/searching the file line-by-line.
|
Download PDF |
Practice Session 1: Inheritance and operator overloading practice
- Practices overriding: mother/daughter classes both define display() with different messages, showing how derived functions can replace base behavior.
- Practices calling the base version explicitly using scope resolution (calling the mother’s display() from a daughter object).
- Designs a Counter class that overloads prefix/postfix ++ and uses a static counter to track how many objects currently exist.
|
Download PDF |
Practice Session 2: Pointers, static, copy constructor, friend access, object lifetime
- Fixes common syntax/logic mistakes involving objects vs pointers (. vs ->, new, dereferencing, and delete).
- Reinforces key concepts with questions on static members, copy constructors, and friend classes (what can be accessed and why).
- Tests understanding of constructor/destructor order by predicting output when objects are created in and out of nested scopes.
|
Download PDF |