Adding two arrays to temp array, what's wrong here?

Pages: 12
Then I don't want to waste his time, if he thinks he can help you by making you think, I'm prepared to let you do that. I don't want to give you the answer you want just to disadvantage you later. Good luck.
I wasn't really looking for the answer before because honestly; this is my major and I really want to know how to due it and being on a deadline is stressful but I'm sure you probably knew that. Anyway it's due tomorrow night and ANY hints or ANY information at all is very helpful and I really do appreciate it.
"You are almost there, the question is who "num" is that in the for loop,
which object does it belong to."

He is talking, of course, of the use of 'num' in the for loop.

You can't just write 'num', because that's not what you mean, you mean Temp.num!

I hope this helps with your project and also helps you practice OOP.
closed account (3TXyhbRD)
Good, finally got the code working :D
The usage of <num> is immense, it's always good to have a variable that has the returned value of an often called function, however thats optimizing and it's what you do after you get your code working.
And as for OOP, you need a good hold of basic C++, working with arrays especially and later on with pointers and dynamic allocation.
Despite being new to C++ I'll defend LilJoe's statement to the death.

Optimisation really shouldn't be touched until we've finished our program. When I write my programs I consider portability, good design practices and try to make the flow make sense. When I'm finished, then I'd make a separate copy for optimisations and try and compile that separately, but only at the end of the whole project.
closed account (3TXyhbRD)
Optimization can come at the end of the whole project or after you wrote a function and you tested it with positive results. I prefer to optimize my functions after I wrote and tested them because if I have a long source code I get lost in it just reading it.

Also a very good idea is to use comments in your source code, like in the example I gave. Even if it's as simple as "declarations" it says what that part of code does without having you to read it.
LilJoe, do you prefer to document what code in the following section does with comments or write comments on lines on the odd occasion to let the reader know what's going on more frequently?

I only optimise functions that aren't complex interfaces, because interfaces usually need something added to them and in an un-optimised form they are easy to add to (generally), whereas optimised the flow of code is no longer logical and slightly more iterative, if you know what I mean?

But a singular function? Yeah, I'd probably optimise that after finding out it worked exactly the way I intended it to, now that I think about it.
closed account (3TXyhbRD)
Like in the example, only that I don't usually write small theory into my codes. Simple phrases or just words (as few as possible and in the same time as clear as possible, like a summary of the following few lines of code). If I have "Declarations", declarations of variables until the next comment.
As for unoptimized functions, yes it is a lot easier to add/change code since it's more readable. However it is up to you to keep it as readable as possible when you start optimizing.
Topic archived. No new replies allowed.
Pages: 12