How can I getting the sum of two Queues in C++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can I getting the sum of two Queues in C++?

I'm trying to solve a lesson that asks to obtein the sum of two queues in C++ unsing operators overloading, but without success. Can anyone help me?

30th Jun 2021, 2:37 AM
Taylon Silva
3 Answers
+ 1
The lesson/ project I assume you are referring to defines the sum of two queues as "a new queue, where the elements of the first queue come first, followed by the second queue's elements". Therefore, what you have to do is to construct a new queue, add the elements of the first queue, add the elements of the second queue, (handle the size if necessary) and return it. You already have member functions for most of this. If you need help with the code, please copy it to a playground project and link that here, otherwise we have no way of knowing what might be wrong.
30th Jun 2021, 6:23 AM
Shadow
Shadow - avatar
0
Yes, that's the lesson. I was trying to do like exemples were made. But it always returns error. I'll try the way you told me.
30th Jun 2021, 11:46 AM
Taylon Silva
0
Thanks 👍
30th Jun 2021, 11:47 AM
Taylon Silva