Skip to main content Skip to navigation

Day 5: Object Oriented Programming with C++

Zoom meeting link for today

https://cern.zoom.us/j/67888545132Link opens in a new window
(the password will be sent on the course Slack channel)

Create new repository for today

https://classroom.github.com/a/Zj4zoZybLink opens in a new window

Structured binding declarations

We start with a brief introduction to structured binding declarations, which were introduced in C++17. We see how they can make code more easy to understand. (PDF Document)

Namespaces

We continue with a brief discussion of namespaces. We see how they can help to group related functions and objects. (PDF Document)

The Vigenère cipher and object composition in C++

We continue by implementing the last of our ciphers: the Vigenère cipher. This requires the use of object composition, a powerful way of resuing code. (PDF Document)

Dynamic Polymorphism in C++

We consider the concepts of polymorphism and shared type in C++ by reviewing the builtin types and templated types as seen in the previous weeks. We motivate sharing type by considering how objects may change through the lifetime of a program and how templates, whilst allowing polymorphic behaviour, lock the behaviour in when our program is compiled. In C++ we show how runtime polymorphism is realised with public inheritance and pure abstract classes specifying an interface. (PDF Document)

Smart Pointers in C++

We see how to use smart pointers to manage the lifetime of objects beyond the scope in which they are created. (PDF Document)