2024-11-19

The day was woven around the screenplay A One-Day Overview Of C++. I used that to live-hack 2024-11-19/intro.cpp - which is the final outcome.

See the script to see how we got there. Any deviations (asked questions, discussions) are documented below.

Course Flow: Questions And Discussions

The following chapters correspond to sections in A One-Day Overview Of C++, which are referred to in their respective sidebars.

std::map, And Pitfalls (Pitfall: Encapsulate std::map Value In class Item)

std::map, when filled using tdl["something"] = Item("... blah ..."), requires class Item to have a default constructor. This is not entirely obvious, to say the least.

Problem: std::map::operator[]() creates a node with a default-constructed value, which is then overwritten with Item("... blah ...").

Solution: use std::map::insert(), or even better in our case at least, use an initializer list and a const todo_list object.

Demo of the pitfall (std::map::operator[]()) in 2024-11-19/map-pitfall-no1.cpp

Brace Initialization

Discussed the differences between {} and (). See 2024-11-19/brace-init.cpp

Smart Pointers, And Move Semantics

While using std::shared_ptr<> in 2024-11-19/intro.cpp, we approached the topic in

While we were at it, we discussed related topics like

Lambda

Transformed 2024-11-19/intro.cpp into something that is more to the point. Talk about interfaces, the cost of virtual (RTTI is not free), and readability in general.

For what a lambda really is, see the old school functor demo (2024-11-19/functor.cpp).

Use cases for lambda: