in the default constructure allocate the array with max number of doubles.
function add_item is all f**ked up. change the name to list::add_item and delete all its contents.
if size == MAX_LIST_SIZE then reallocate the array, otherwise just insert the new number into list[size++];
Ancient Dragon
Retired & Loving It
30,047 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,342
void list::add_item(double number)
{
if (size == max )
{
// reallocate the array
ArrayPtr m = new ArrayPtr [max + MAX_LIST_SIZE];
// copy existing data into new array
memcpy(m, list, size * sizeof(double));
// delete old array object
delete[] list;
// reset list
list = m;
// bump array size
max += MAX_LIST_SIZE;
}
// add number to the list
list [size] = number;
size++;
}
I'm not getting it. Once I check the size, add it and then count.....else just add the record???[/QUOTE]
Ancient Dragon
Retired & Loving It
30,047 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,342