Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок0
Problem with operator overloading
This code is supposed to add objects together by adding their arrays and size. The second array is always zero and I don’t know why I considered doing two loops but I want to know what’s wrong here first https://code.sololearn.com/cVb8Pc55pGpS/?ref=app
3 ответов
+ 4
Check again ll.41-44. That loop works incorrectly. What happens is that you overwrite the values at i+size with the zeroes from the first queue after i reaches size.
You need to add one queue, and in another loop the other queue. It doesn't go with just one loop since the sizes can be different.
+ 3
Ty, trying to do everything in one loop made me slip up 😅
+ 3
You're welcome :)