This section of the activity is optional, and directed towards students who would like to explore higher levels of control of memory management with C++.
- Extend the previous activity to record an sequence of colour of unspecified length.
In the exercise 1, you had to record a fixed number of colours in a data structure (array) of fixed size. We would like here to provide more flexibility to the user by letting them indicate the end of the recording sequence. The main implication is that we can't initiate the array in the same; we need to control its size dynamically.
Learning objectives
- Learn about dynamics memory allocation
- Detect more complex button events - the double click!
Working code for the extension project: :download:`code <./solutions/solution_project_1_ext.cpp>`.