- #1
AcecA
- 12
- 0
Homework Statement
All I need is an explanation as to why the algorithm I've been given doesn't destroy the queue properly. When I use the code below, and I check if q is NULL or not, it says it isn't, and I'd like to know why. Thanks :)
Homework Equations
None, this is computer science.
Langauge is C with some C++ conventions, by the way
The Attempt at a Solution
Code:
typedef int Element;
struct _Queue {
Element *elts;
int head;
int capacity;
int count;
};
typedef _Queue* Queue;
void DestroyQueue(Queue q)
{
delete[] q->elts;
q->elts = NULL;
q->head = 0;
q->count = 0;
delete q;
q = NULL;
}