السسلام عليكم ..
لو سمحتوا ي اخواني ممكن احد يصحح لي هالكود , ويقول لي ايش الغلط ..؟ هو مايدخل الا عنصر واحد ويقول underflow
وفقكم الله .
#include <iostream.h>
struct QUEUE
{ int info;
QUEUE *pNext;
};
QUEUE *rear=NULL, *front=NULL;
class queue
{
private:
int ITEM;
public:
void Enqueue ()
{int ITEM;
cout<<":ENTER ELEMENT ";
cin>>ITEM;
QUEUE *NewNode;
NewNode = new QUEUE;
NewNode->info = ITEM;
NewNode->pNext = NULL;
if (rear == NULL) front = rear= NewNode;
else
{
rear->pNext = NewNode;
rear = NewNode;
}
}
int Dequeue(void)
{ if(front == NULL) { cout<<" \n <Underflow> QUEUE is empty\n";
return 0;
}
int ITEM = front->info;
if(front == rear ) front=rear=NULL;
else front = front-> pNext;
return(ITEM);
}
void Traverse(void)
{ if(front == NULL) { cout<<" \n <Underflow> QUEUE is empty\n";
return;
}
QUEUE *f = front;
while(f!=NULL)
{ cout<< f->info<<", ";
f=f->pNext;
}
}
}; // end of the class
int main(void)
{
queue obj; // object creation
obj. Enqueue();
obj. Dequeue();
obj.Traverse();
return 0;
} // end of of main() function

