Weekly Summary
Week 1
Lecture 1
date:
Lecture 2
date:
Week 2
Lecture 1
date:
Lecture 2
date: 25/4/24
- slides: 27 -
- testing with googletests
- googletests has to be cloned into the project as a submodule and build together with your code.
- templates
- template templates
- renaming types with
typedef
- classes and structs
- essentially the same thing, only difference being the default visibility:
public
forstruct
. - access specifiers:
private
,public
,protected
- friend class
- constructors (they are a little messy in c++ due to legacy code issues)
- move constructor:
- converting constructors (implicit type conversions) \(\rightarrow\) hard to find bugs.
explicit
keyword.- conversion operators.
- delegating constructors.
- destructors \(\rightarrow\) RAII (resource acquisition if initialization)
- the rule of zero or five.
- mutable members
- the singleton pattern (single source of truth)
- essentially the same thing, only difference being the default visibility:
Week 3
Lecture 1
date: 29/04/24 - Monday
- basic cmake concepts
- Sheet 2 execises discussion
- basic googletest inclusion - slides are sufficient
- presentation proposal should have a presentation date.
Lecture 2
date: 02/05/24 - Thursday
- slides: 02 - standard
- review of past lecture:
- templates
- typedef
- classes & structs
- constructors
- destructors: deep copy
- fundamental concepts of c++: inheritence
- little inheritence example
- deadly diamond of death
- composition over inheritence
- public vs private/protected inheritence
- is-a vs has-a
- SOLID principles
- discussion of the Liskov Subtitution Principle (LSP)
- project structure
- header files, header guards
- source files separate from headers (templates go against this)
- namespaces to structure and prevent name clashes
- c++ standard library:
- overview
- standard input/output, standard error
- containers and companion classes
- sequences \(\approx\) arrays: array, vector, deque, list, forward list
- container adaptors stack, queue, priority queue
- associative containers \(\approx\) hash map: set, multiset, map, multimap
- unsorted associative containers: unordered set/multiset/map/multimap
- iterators: generalization of pointer concept, they can be dereferenced and advanced to show to the subsequent element
- algorithms: tailored to dfferent iterator categories, make full use of the capabilities of the container.
- functional programming examples
- Error Handling:
assert
: Run-time sanity checkstatic_assert
: compile check with a similar purpose for template meta programmingexception
: error handling mechanism for situation that should not be the norm- discussion of exceptions
Week 4
Lecture 1
date: 06/05/24
- slides: 03 - advanced
- Inheritence & dynamic polymorphism further discussions.
- polymorphism
- static polymorphism \(\approx\) early binding
- dynamic polymorphism \(\approx\) late binding
- simple c++ illustration with the keyword
virtual
, references etc…
- c++ implementation of dynamic polymorphism using
vtables
(dispatch tables). - cost of polymorphism
- copying polymorphic types
- abstract base class (with a pure vitual function)
- factory pattern (it is a creational pattern)
Lecture 2
date:
holiday
Week 5
Lecture 1
date: 13/5/24
- solutions to the exercise sheet 2
- presentations:
- git branches & tags
- IDE’s
- valgrind
Lecture 2
date: 16/5/24
- c++ 11 features: (slide 95)
- automatic type deduction
- trailing return type
- move semantics. Before c++ 11 there were two types of variables:
- values: assignment creates a new independent entity
- references and pointers: assignment creates and alias
- copy constructor:
- deep copy \(\Rightarrow\) value semantics
- shallow copy \(\Rightarrow\) reference semantics
- c++ 11: third type of semantics: move semantics
- forwarding references are not
- smart pointers
- unique pointers:
unique_ptr
- shared pointers:
shared_ptr
- weak pointers (non-owning):
weak_ptr
- raw pointer usage should be avoided
- so basically in modern c++ two types of pointers
- owning pointers:
unique_ptr
,shared_ptr
- non-owning pointers:
weak_ptr
- owning pointers:
- pitfalls:
- unique pointers:
- lambda expressions & closures: generalization of functors in c++
- currying: \((\mathbb{N} \times \mathbb{N}) \rightarrow \mathbb{N} \equiv \mathbb{N} \rightarrow (\mathbb{N} \rightarrow \mathbb{N})\)
- builder pattern with lambda functions
- random number generators
- time measurement (slide 123)
Week 6
Lecture 1
date: 20/05/24
- holiday
Lecture 2
date: 23/05/24
- solutions & presentations
Week 7
Lecture 1
date: 05/27/24
- review of c++ 11 features from previews lectures:
auto
keyword: when to use it.- move constructors and move assignment
- shared pointers, weak pointers, unique pointers.
- lambda expressions, functors.
- random number generators
- range based loops
- advanced topics:
- inheritance and dynamic polymorphism
- resource acquisition is initialization (RAII)
- template specialization:
- function template specialization, vs
- class template specialization
- templates vs inheritance
- achieving the same effect as dynamic polymorphism with static polymorphisdm \(\Rightarrow\) CRTP (curiously recurring template pattern)
Lecture 2
date:
Week 1
Lecture 1
date:
Lecture 2
date:
Week 1
Lecture 1
date:
Lecture 2
date:
Week 1
Lecture 1
date:
Lecture 2
date:
Week 1
Lecture 1
date:
Lecture 2
date:
Week 1
Lecture 1
date:
Lecture 2
date:
Week 1
Lecture 1
date:
Lecture 2
date:
Week 1
Lecture 1
date:
Lecture 2
date:
Week 1
Lecture 1
date:
Lecture 2
date: