0

Question re "adding" arrays together

Well, I tried asking this on Stack Overflow. Really unhelpful, three people made comments unrelated to my question then a moderator closed off commenting before I could clarify. I really don't like Stack Overflow sometimes! Anyway, in the C++ course, the challenge of Queue Management part II is to join together two arrays/vectors with a member function in a class that returns a new Queue object (of class Queue). I tried this: myClass& operator +(myClass &obj) { obj.myArr[size] = this->myArr[size] + obj.myArr[size]; return obj; } It doesn't return the two functions joined together, it just returns obj (which is the second array/vector). I'm a bit stumped. I could solve it if I rewrote the entire format of the program, but that would defeat the point. What error have I made in my program? One... person on Stack Overflow said I was trying to add two pointers, but I'm not - they're integer values. I get an error when I try to add pointers, anyway.

10th Jan 2022, 9:00 AM
Mimsy
7 ответов
0
Return the two objects joined together, then. It is not unrelated, I rewrote the program with myClass instead of Queue so as to make what I am doing clearer. In the overloaded + function, I used the obj parameter, which contains the second array, and this keyword, which “contains” the first array, and added them together. However, your own answer is unrelated to my question, so forget it. Just forget it. You assume I have done no reading or research before asking. Maybe I have, and was still stuck and that’s why I asked. Never mind. I will not ask again.
10th Jan 2022, 6:46 PM
Mimsy
0
No need to throw a hissy fit… Martin, I strongly suggest you think about what you are trying to achieve before you speak. In life, as in programming, it’s a big help. Enjoy your teddy.
11th Jan 2022, 4:38 AM
Mimsy
0
"I'm surprised that SO didn't eat you alive!" that made my day. " what I'm trying to achieve is to teach a galah how to code and failing miserably." if anyone's is too lazy to search, it means a rose-breasted cockatoo
11th Jan 2022, 4:21 PM
Rellot's screwdriver
Rellot's screwdriver - avatar
0
Here’s why I made the comment about thinking before speaking. I posted a question. Martin responded with no intention of actually helping, he just felt compelled to call me an idiot. Now, what does that say about Martin? Now RS felt compelled as well. Guys, if you have no intention of actually answering the question, then just move on. You don’t need to show everyone how incredibly clever you are. As it happens, I got some real help elsewhere, and I most definitely will not be asking a question on Sololearn again if this is the level of maturity of its members.
11th Jan 2022, 7:11 PM
Mimsy