Homework: C++ Vector Implementation

Due: Monday, November 25, 2024, at 11:59pm

Jump To:

Goals
Synopsis
Set-Up
Provided Files
Your Task
Assessment
Turn-in instructions

Assignment Goal

This assignments provides practice with basic C++ functionality, including class defintions, heap memory usage, and namespaces.

Synopsis

You will create a C++ class Vector that implements 3-D vectors. A header file is provided that describes the required functionality for this class, and you will implement each method or function required to support the class. You will use C++ techniques.

Set-Up

Before you get started, ensure that your set-up is up-to-date and appropriate.

  1. You should do this assignment using cancun, including g++
  2. Ensure that your repository is up-to-date and committed. (You can use git status to determine if there are outstanding changes, and git add and git commit if you are unsure.)
  3. Use git pull upstream main to pull the newest commit from the upstream repository. This will give you access to the hw8 folder containing the materials for this assignment. (upstream specifies that you want to pull from the upstream repository, and main specifies the branch. You may see a text editor open to allow you to edit the merge message. This will likely be Vim, so you can edit it and then save, or just accept the current text and exit using :q!.)

You will do this assignment in your new hw8 folder. You should get into the habit of committing and pushing code frequently.

Provided Files

Your hw8 folder contains the following files:

Your Task

You will create a C++ class Vector that implements 3-D vectors. This class will be defined in the file Vector.cc. You should not modify any of the starter files provided for this assignment.

In file Vector.cc implement the Vector class with the following properties:

Note: Pay attention to the data types of the specified functions. This code makes use of references, and also sometimes requires returning a Vector (not a pointer to a Vector). You should take care to create your Vectors and return them appropriately.

Code Quality

You should ensure that your code follows typical guidelines regarding variable naming. You may include comments as necessary for any tricky parts of your code. You will also want to use cpplint.py to check that your code complies with the style guidelines before submitting.

Assessment

This assignment will be worth 40 points. Your code will be evaluated by an autograder. You are welcome to submit again in order to achieve a better score, but, you should use your hw8 exectuble to test your code before you do so. Be sure to fix warnings or errors that occur during compilation, and then compare the ouput of your code to the target output.

Turning In

You will submit this homework to the Gradescope HW8: C++ Vector Implementation, via Gitlab. You should commit your work to your repository, including your Vector.cc file. These files will be located in the hw8 folder at the top level of your repository.

Once you locate the Gitlab assignment you will tap the "GitLab" button on the bottom:

Picture of Gradescope interface highlighting the Gitlab button as opposed to the Upload button
Find your 374 repository in the list, and Submit Project.
Picture of Gradescope submission interface

Once you submit your code the autograder may take some time to run. You may resubmit for a higher grade, but your should always do as much testing as possible on your own platform before resubmitting.