NOTES ON PROJECT 1

Qshow and Qnext are not void methods. They return a "void pointer"

specifically:

void *Qshow(qytpe);

This void pointer is the same void pointer provided as the 2nd argument to Qadd:

int Qadd(qtype, void *);

The type of data stored in the queue is a void pointer - which is a pointer whose type is unknown. The queue code doesn't know what the pointer points to. It only knows its a pointer.

So here is an example of using the queue:

qtype myqueue;

int i, *p;

myqueue = Qnew(); // create a new queue

i = 4;

Qadd(myqueue, &i); // put a pointer to i in the queue

p = Qshow(myqueue); // get a pointer out of the queue

printf("%d\n",*p); // this should print 4

Dr. Ligon