CSCI 330 bonus lab: using C++ smart pointers
The objective of this lab is to get experience with the use of smart pointers
(shared_ptr, weak_ptr, unique_ptr, etc) in C++.
The exercise itself is fairly straightforward:
- The repository contains an implementation of a program to read rankings from a file
and store them in a linked list (much like our earlier labs but in C++)
and run a series of head-to-head matchups between them,
with mergesort/merge functions to sort the lists before writing them
back to the original file.
- The files all currently use raw (dumb) C++ pointers.
- The objective is to convert them to make appropriate use of C++ smart pointers
(using shared_ptr, weak_ptr etc from the <memory> library).
The code comes from one of this term's CSCI 161 assignment (if you're curious,
see csci 161's lab3).
We care less about the program behaviour here, instead caring more about the
correct/appropriate handling of memory through smart pointers.
Some sample code is available for a 'smart' linked lists,
with a main routine that illustrates much of what is taking place in the sample code.
Discussion of smart pointers (slides and video) can be found on the
lecture resources page. The concepts still hold,
but most of the syntax is from an antiquated implementation of the shared pointers.
The repo can be obtained and submitted in our usual git fashion, with 'bonus' as the repo name
(instead of labX).
The bonus lab mark can be used to replace one lower lab mark.