DPA 4010 / 6010

Spring 2016

C++ Vector Class

Homework Assignment 7

Due: Midnight, Wednesday April 13


Assignment:

This week your assignment is to to write a C++ two-dimensional vector class. There is no graphics component to this problem. The idea is to implement all of the functionality that you will need for handling 2D vectors, so that you can use them in future assignments. The program should consist of a class definition, implementations for all member functions, and implementations for all overloaded operations that can be performed on the vectors, and a main program that allows the user to interactively test the vector class using text input and output.

Your vector class should have appropriate constructors, set and get procedures for managing vector coordinates, member functions to compute vector length or magnitude, and the unit vector parallel to the vector. Operators should include vector addition and subtraction, multiplication by a scalar, and inner (dot) product.


Advanced Extension: Include operator overloading in your vector class to allow stream-I/O input and output of a vector via the >> and << operators.

Please submit your program using the standard handin procedure. You should include your all of your source code .cpp and .h files, and a Makefile.