Question: How to use concatenate for linked lists with this format? this is what i have QueueT QueueT::concatenate(QueueT& qu, int n)const{ QueueT result = front; QueueT

How to use concatenate for linked lists with this format?

How to use concatenate for linked lists with this format? this is

this is what i have

QueueT QueueT::concatenate(QueueT& qu, int n)const{

QueueT result = front;

QueueT re = qu;

int stop = 0;

//while it is not empty, we want to for the size n, iterate and insert the first n values

if(n > re.size()){

throw std::runtime_error("n is greater than size of param");

}

while(stop != n){

result.enqueue(re.front->data);

re.dequeue();

stop++;

}

return result;

}

and my test program calls it like this, q1.concatenate(q4, 1); but i do not know how to reach both linked lists

concatenate - has two parameters, a QueueT reference and an integer (referred to as n in this description) adds the first n values stored in its Queuet parameter to the end of the calling object, the resulting queue therefore contains its original contents - order unchanged - followed by the first n values of the parameter queue in their original order; the values added to the calling object should be removed from the parameter; both queue's sizes should be adjusted as appropriate; if n is greater than the size of the parameter a runtime_error should be thrown and no changes made to either queue

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!