ok im trying to change this from link list to a queue.bt whenever i run it it sill shows from last to first which is the opposite from what i want.here it is, i hope somebody can try to see whats wrong with it.
#include<iostream.h>
#include<conio.h>
struct queue
{
int data;
queue* next;
};
class queueL
{
protected:
queue* last;
queue* first;
public:
queueL()
{last = NULL;}
void additem(int d);
void display();
};
void queueL::additem(int d)
{
queue* newqueue = new queue;
newqueue->data=d;
newqueue->next=last;
last = newqueue;
}
void queueL::display()
{
queue* current = last;
while(current!=NULL)
{
cout<<endl<<current->data;
current = current->next;
}
}
void main()
{
queueL ql;
clrscr();
ql.additem(25);
ql.additem(36);
ql.additem(49);
ql.additem(64);
ql.display();
}