Managing my array
Apr 18, 2012 at 1:04am UTC
So I have this template based class which has an array,
queue<T> * items[MAX_HEAP];
, and I want to test if the array is empty. How would I do this? I've tried:
1 2 3 4 5
queue<T> *itemsPtr = items[0];
if (itemsPtr->size() != 0){
...
}
but that gives me an run time exception...
Also, how would I point my itemsPtr to the next element in my array?
Last edited on Apr 18, 2012 at 1:07am UTC
Apr 18, 2012 at 1:25am UTC
but that gives me an run time exception...
Has the array been initialized?
Apr 18, 2012 at 1:37am UTC
Yeah, I do something along the lines of:
1 2 3 4 5
queue<T> * elementQueue = new queue<T>;
elementQueue->push(newItem);
// place the new item at the end of the heap
items[size] = elementQueue;
Apr 18, 2012 at 2:14am UTC
Is that size variable, that's used as an index, the correct value?
Topic archived. No new replies allowed.