You are to create two different classes. Both of these classes are simply ways of storing a list of doubles. One class uses an array, the other uses a linked list. The classes each provide reader and writer functions.
Print out all the doubles in the list. Ideally in a ``pretty'' way and in a way. It must be clear what the ordering is inside of the list. You have a lot of flexibility in the implementation of this function.
double& operator[](unsigned idx); or why you would want to.
Suppose you have
class X
{
double data[100];
public:
double& operator[](unsigned idx) { return data[idx]; }
};
then you can write
X x;
x[1]=-1.2345;
x[2]=x[1]+100;
and so on.
If you happen to forget the & sign,
the lines starting with x[1] and x[2] won't compile.
Instead of that one operator, you could do something like
double getValueByIndex(unsigned idx) const { return data[idx]; }
void setValueByIndex(unsigned idx, double val) { data[idx]=val; }
then the four lines above would look like this:
X x;
x.setValueByIndex(1,-1.2345);
x.setValueByIndex(2,x.getValueByIndex(1)+100);
cout << x.getValueByIndex(2) << endl;
which one looks more better/easier ? :)
Also, example 24 at this C++ site provides some insight on the issue.
Nope. Those multi-argument constructors (EECS380_DynContainer(unsigned maxSize, unsigned size, double val) for example)
require initializing `size' values to the same value. Not what is wanted for
part 3.
Not really. We gave a few extra days (and some extra points) because the instructors felt it was pretty long for 2% of your grade. But it really shouldn't take that long. After all: