CSE 333 25sp Exercise 9

out: Friday, April 25, 2025
due: Monday, April 28, 2025 by 10:00 am, No late exercises accepted.

Goals: Create and use a complete C++ class for a new 3-D Vector abstraction, including constructors, destructors, operators including assignment and stream output, and a simple user-defined namespace.

Description: Create a C++ class Vector that implements 3-D vectors.

Hints: You will find the complex_example code from lecture very useful as a model for this exercise. That code demonstrates several ways to implement operators; do not feel obligated to use all of them -- use the ones that make the most sense. However, not all of the operators can be implemented as member functions of the class, so you should expect to have some non-member operator functions in your solution. Also, it is generally considered good practice to minimize the number of member functions that have access to private details inside the class if it is possible to do the job equally well with a non-member function.

You will find this exercise goes much faster if you implement operators and write test code for them one at a time, instead of trying to do everything all at once.

Feel free to base your Makefile on the one presented earlier as an example in class (i.e., you might want to download a copy of that Makefile and make suitable modifications to create one for this exercise).

Advice: get the Makefile working early, as soon as you've got a minimal set of source code to compile, and before adding all the different operations. That should save a lot of time because after each change you can just type make to re-build everything and not need to type lots of lengthy g++ commands.

Advice: Implement stream output (operator<<) early so you can use it to print Vector values using cout << v as you add operations to your Vector class.


Your code must:

You should submit your exercise using the Gradescope dropbox linked on the course resources web page.