Implement a templated C++ class Vector that manipulates a numeric vector. Your class should be templated with
Question:
Implement a templated C++ class Vector that manipulates a numeric vector. Your class should be templated with any numerical scalar type T, which supports the operations + (addition), − (subtraction), and * (multiplication). In addition, type T should have constructors T(0), which produces the additive identity element (typically 0) and T(1), which produces the multiplicative identity (typically 1). Your class should provide a constructor, which is given the size of the vector as an argument. It should provide member functions (or operators) for vector addition, vector subtraction, multiplication of a scalar and a vector, and vector dot product. Write a class Complex that implements a complex number by overloading the operators for addition, subtraction, and multiplication. Implement three concrete instances of your class Vector with the scalar types int, double, and Complex, respectively.
Step by Step Answer:
Data Structures And Algorithms In C++
ISBN: 9780470383278
2nd Edition
Authors: Michael T. Goodrich, Roberto Tamassia, David M. Mount