Week 10 Class 17 Tue Mar 18 Posted: Mar 18
After Class * Exercise 49: Convert II This exercise is extra credit. I will drop another lowest-exercise score.
Announcements
Agenda
Exercise 52: Lambda
Follow along in your commits as we explore what we can get from the context of the lambda definition.
Exercise 54: Memory
The file Memory.cpp in the repository Memory contains many memory resource problems described in the notes.
Compile and run the program on your platform (i.e., your compiler and operating system). You may or may not see a memory-related issue during the build and run.
Go to a system where you can run valgrind. Following the instructions in the Guide: Valgrind, compile and run valgrind on the program.
Fix the memory resource problems in Memory.cpp without using std::unique_ptr. Do this for each section one by one committing each section separately. Get the code to the point where it compiles and runs successfully, and you have a clean Valgrind run.
Once done, tag this in Git as memoryfixed.
Exercise 55: Names
The UML Class Diagram shows Name with attributes that are single-value optionals.
Convert the source code class to use std::optional<std:string>
instead of the pair of std::string
and a boolean flag.
The link for GitHub Classroom is in Brightspace.
Due 4:30 pm on Friday, Mar 21
Reminder The type String
in a UML Class Diagram does not necesarily map to a std::string
in a C++ program. It could map to a std::string_view
, or even a c-string. Which source-code type a UML type maps to is part of the code implementation, and not part of the model*.
Exercise 49: Convert II
Following my example in class as we rearrange the concerns and apply changes to the file to separate the concerns.
Unless otherwise noted, exercises are due by 4:30 pm on Wed Mar 19