For this assignment you will create a class template called VecXd which represents the mathematical concept for vectors. The purpose of this assignment is to have you implement a non-trivial class from scratch without using the STL and review the basics of C++. For this assignment you should not include any libraries except iostream and cstdlib.

A vector can have any dimension which is a positive integer that defines how many values are contained in the vector. Given a vector’s dimension you will have to dynamically allocate an array to store the elements of the vector. Do not use an STL vector class to do this. You may use the C++ keywords “new” and “delete” to do this.

Your class should be defined as a class template so that it will work with a variety of numerical types including int and double. Pay special attention to the implementation of the destructor, copy constructor, and assignment operator. The book covers these in detail and they must be correctly implemented. Additionally you must overload operator+ and operator+= to perform vector addition. The corresponding elements of each vector are added to produce the sum of two vectors. Only two vectors of the same dimension may be added together. Fail gracefully on an illegal operation.

Finally, you must overload operator<< and operator>> to perform input and output. Operator>> should expect to see input in the following form: d v1 v2 … vd , where d is the dimensionality of the vector and each vi is the value corresponding to index i in the vector. Operator<< should simply output the elements in order. For this assignment you will be provided with a file called test.cpp which contains a testing routine for the VecXd class template.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.