CS 311 Fall 2024  >  Assignment 5


CS 311 Fall 2024
Assignment 5

Assignment 5 is due at 5 pm Thursday, October 31. It is worth 65 points.

Procedures

This is, optionally, a group assignment. You may work in a group of two, if you wish. Each group only needs to turn in a single copy of the assignment. Under normal circumstances, each group member will receive the same grade on the assignment.

Turn in answers to the exercises below on the UA Canvas site, under Assignment 5 for this class.

If you work in a group:

Exercises (65 pts total)

Exercise A — Generic Frightfully Smart Array Class Template

Purpose

In this exercise, you will write a class template that acts as a “smart array”. It will be significantly better than the array class from Assignment 2—and almost as smart as std::vector. In particular, the array will be resizable and exception-safe, as well as efficient.

Key to this assignment is exception safety. Make sure that exceptions thrown by value-type operations are properly handled, and that all safety guarantees are documented.

And as always, make your code high quality.

Instructions

This assignment may be done individually or in a group of two.

Implement a C++ class template that manages and allows access to a resizable array. The type of item in the array is specified by the client code. Be sure to follow the coding standards. All standards now apply!

Other than the class name and the fact that it is a class template with a client-specified value type, the interface for GFSArray is that covered in recent class meetings. This interface is as follows.

In addition:

Test Program

A test program is available: gfsarray_test.cpp. If you compile and run the test program (unmodified!) with your code, then it will test whether your code works properly.

The test program requires doctest.h, the header for the doctest unit-testing framework, version 2.

Do not turn in the test program or the doctest framework.

Notes