Problem with operator overloading | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
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

11th Mar 2023, 1:22 PM
Ayman Abdraboh
Ayman Abdraboh - avatar
3 Respuestas
+ 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.
11th Mar 2023, 2:25 PM
Ani Jona 🕊
Ani Jona 🕊 - avatar
+ 3
Ty, trying to do everything in one loop made me slip up 😅
11th Mar 2023, 2:39 PM
Ayman Abdraboh
Ayman Abdraboh - avatar
+ 3
You're welcome :)
11th Mar 2023, 2:53 PM
Ani Jona 🕊
Ani Jona 🕊 - avatar