Beginner level · Module 4 of 5 · 11 guided hours
References, Pointers and First Classes
Understand memory addresses, references and pointers, and model real things with simple classes.
Learning objectives
- Explain references and pointers and use them correctly
- Avoid null and dangling pointers
- Write a class with private data, a constructor and member functions
Topics
- memory and addresses
- references
- pointers, & and *
- nullptr
- classes and access specifiers
- constructors and member functions
Lessons
-
Lesson 1 References and Pointers
See how variables live at memory addresses, and use references and pointers to refer to them.
address-of &dereference *nullptrdangling pointer
-
Lesson 2 Your First C++ Class
Define a class with private data and public member functions, and create objects from it.
classpublic and privatemember functionobject
-
Lesson 3 Constructors and Keeping Objects Valid
Initialise objects with constructors and member initializer lists, and enforce rules in member functions.
constructormember initializer listinvariantstd::invalid_argument
Practical activity
Write a WaterPoint class with a name, a daily reading and a status, and a function that marks points below a threshold as needing repair.
Expected outcomes
- Correct use of references and pointers in small programs
- Simple, encapsulated classes
Assessment
Short written check on references versus pointers, plus a practical class exercise reviewed against a checklist.
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.