Hello. I'm currently making a program that deals with a priorityQueue and inheritence/polymorphism.
Student -> undergrad -> coop_student
or
student -> grad
Now, the queue takes in the data and just puts it in a linked list and gives it a priority. That way, there are 3 queues and we dequeue from the first going to last.
Here are the snippets that have the problem.
Note: I was told that I don't need an operator=, but if I do, I can add one.
priorityQueue.cpp:30: error: no match for ‘operator=’ in ‘n->node::data = theStudent’
void priorityQueue::enqueue( student * theStudent, int priority )
{
if( priority > 3 || priority < 1 )
return;
priority--;
node *n = new node;
n->data=theStudent;
n->next=NULL;
node *p;
main1.cpp:32: error: invalid conversion from ‘int’ to ‘student*’
main1.cpp:39: error: invalid conversion from ‘int’ to ‘student*’
Both of these redirect to the dequeue
nt priorityQueue::dequeue()
{
for(int i=0; i<3; i++)
{
if(queues[i] != NULL)
{
int returnnum;
node *temp;
temp = queues[i];
if(queues[i]->next != NULL)
{
queues[i]=queues[i]->next;
returnnum = temp->data;
delete temp;
return returnnum;
}
else
{
queues[i]=NULL;
returnnum = temp->data;
delete temp;
return returnnum;
}
}
}
return 0;
}