It dosen't work, because your class design is half baked.
It is all doomed to failure.
In the default constructor
floatArray::floatArray() you say that you have
now set the
mData member to 0. What about the
mSize member.
In this other constructor:
1 2 3 4 5
|
floatArray::floatArray(int size)
{
size=mSize; //What????
//Also what about the mData member????
}
|
In this function: - Is this enough??
1 2 3 4
|
void floatArray::resize(int newSize)
{
mSize=newSize;
}
|
Come to think of it - what is the purpose of the mSize member - does it show how many actual values are use in the array - or the actual size of the array
bnecause those are two different things.
In this function
1 2 3 4
|
float& floatArray::operator[](int i)
{
return mData[i];
}
|
There are absolutely no checks for array out of bounds access - or
wherther the
mData pointer is valid. (The mData pointer will be INVALID
after a floatArray variable is created with the default constructor because mData is 0).
Oh the list goes on and on....