CS11 Intro C++ Lab 7: Integer Matrix II

Hopefully you didn't find last week's lab too difficult to get working properly. This week you will continue to work on your Matrix class, adding matrix arithmetic operators (+, - and *, along with the corresponding compound-assignment operations), and also implementing move operations so that the compiler can use your class as efficiently as possible.

Move Operations

C++ is very careful about move operations: If your class implements its own custom copy comstructor, copy-assignment operator, or destructor, the compiler assumes that the default move operations will likely be incorrect for your class, and it will not generate any move operations. Is this a problem? Not really! Move operations are about improving performance, not maintaining correctness. That said, a move operation that functions incorrectly will definitely make your program crash or behave in confusing ways. Therefore, since it won't break the program to leave out the move operations, the compiler does the safe thing and leaves them out.

However, if you have a class where move operations are a good idea, and you already need to implement copy-construction and copy-assignment, then you also need to implement your own custom move-constructor and move-assignment operators that do the Right Thing for your class. This is an example of the Rule of Five, which is the C++11-and-later equivalent of the Rule of Three.

Provide implementations of the move operations on your Matrix class:

Other Operations

To give us a proper opportunity to exercise move operations, we should add the simple arithmetic and compound-assignment operators that are relevant to matrices! Provide implementations of these operators:

Coding Style

As with last week, comment all new functionality thoroughly in the Doxygen style, including a class-level description, and a comment for every data-member and member-function. (Comments may be brief if the function's purpose is obvious, but you must still comment all of these things.)

You do not need to create a Doxyfile or run Doxygen this time, as long as you follow the Doxygen format properly.

Make sure to always identify what arguments are illegal. Additionally, always document any exceptions that may be thrown, and the circumstances that would cause them to be thrown.

Testing

A test suite for your class is provided here; make sure to fix any test failures you encounter.

Build Automation

As before, you will need to submit a Makefile for your project that builds and tests your Matrix code.

Submitting Your Work

Once you have completed the above tasks, submit your work through csman. Make sure to submit these files:

You do not need to submit the test code; we will test your program with a fresh copy of these files.

Assignment Feedback Survey

Please also complete and submit a feedback survey with your submission, telling us about your experience with this assignment. Doing so will help us to improve CS11 Intro C++ in the future.


Copyright © 2019 by California Institute of Technology. All rights reserved. Generated from cpp-lab7.md.