Vector
class. In the context of this assignment, a Vector
is,
essentially, a point in n-dimensional space. That is, a
Vector
has n components, each of which is a
double
. Note that, in the context of this assignment, a
Vector
is not a "resizable array". That is, in the
context of this assignment, a Vector
has a fixed size.
This assignment is both about vector arithmetic and about C++. With regard to the former, you must implement various operations. With regard to the latter, you must use return by reference, operator overloading, exceptions, and initializer lists.
Vector
class is available on-line:
Vector ( Design )
begin()
method returns a pointer to the first
element of an initializer list. So, in the following example,
values
points to the first double
(in the array of double
values) that is associated with
v
.
void doSomething(std::initializer_list<double> v) { const double* values; values = v.begin(); // Work with the array }
At this point in the semster, you must use a testing methodology that is, admittedly, awkward. Specifically, your driver must generate the expected output and the actual output for each test case, and you must visually compare the two. The output must be formatted as follows:
For example, one test case for the function
Vector operator*(double k, const Vector& a)
might look
like:
Vector operator*(double k, const Vector& a) Test 1 Multiplication by a positive constant Expected Output: - - | 5.00 | | 8.00 | | 3.00 | - - Actual Output: - - | 5.00 | | 8.00 | | 3.00 | - -
==
operator
fairly early in the process.
It is strongly recommended that you design, implement, debug, and test one method/function at a time.
Copyright 2014