home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_11_01
/
1101095b
< prev
next >
Wrap
Text File
|
1992-11-03
|
519b
|
22 lines
//
// float_array::operator[] that extends the array on
// subscript out of bounds
//
float &float_array::operator[](size_t i)
{
if (i >= len)
{
float *new_array = new float[i + 1];
assert(new_array != 0);
size_t j;
for (j = 0; j < len; ++j)
new_array[j] = array[j];
for (; j < i + 1; ++j)
new_array[i] = 0;
delete [] array;
array = new_array;
len = i + 1;
}
return array[i];
}