I have an assignment from my programming class, which is very poorly worded... The following line really stumps me. We're creating a class called FloatArray, which contains an array (arr
, which is just a pointer to a bunch of floats
).
The default constructor FloatArray(); should create array of zero width and zero height.
I have no clue what my professor means by that... Does anyone else? We're required to provide another constructor, which indicates the height and width of the array. That's fine and dandy - just plug in the numbers, and allocate away... But what does he mean by "create array of zero width and zero height"?
Just so you know, the array is simply defined as:
float *arr;
Help me understand this madness! If it were up to me, I wouldn't even make a blank constructor for such a class...
Regardless - am I overlooking something here? Is this some kind of terminology I've never encountered before, or am I correct in stating that this is madness?
Should I just do the following in the default constuctor?
*arr = 0;
Because I can't do arr = new float[0]
, now can I :P (Or maybe I can - I just tried it (thanks Thomas!) and it compiles and runs... !?)
Does this mean that when I do arr = new float[0]
, arr
points to some location (the beginning?) on the heap?
I know this question seems quite vague, but that's how the entire assignment is - very poorly worded. I just want to make sure it's not just me!