First, I will talk about the code, then I will take out your comments.
You're wasting execution time by allocating an extra array. aTempArray is completely useless the way you use it.
Instead of:
Code:
allocate temporary array (old size)
copy array into temporary array
free array
allocate array (new size)
copy temporary array into array
free temporary array
You should be doing:
Code:
allocate temporary array (new size)
copy array into temporary array
free array
assign temporary array to array
Another thing is that you should put
Code:
myIndex = index_in;
out of the conditionnal branches because it is done either way.
And, you shouldn't be using myIndex as the index right now because myIndex has the value of index_in, so instead of using a member variable, use a local one.
Lastly, the makes no sense as you use unsigned indexes and we have index_in > myLastIndex; thus, index_in cannot be equal to zero, even if myLastIndex's value were zero, index_in would be greater than zero.
Quote:
I thought of that, but I tried to build first an easy-to-understand example. Later it will be optimized and error handling will be also introduced.
It sounds quite funny, you are teaching one of the most difficult point in the C++ language, though you bother with your students not understanding memcpy()?
Quote:
Lyx, sorry if I caused you such a great problem, headache, maybe nearly brought you to suicide
You just can ignore the topics and don't bother yourself if you are such a sensitive person.
Just don't make fun of me with your suicide thing, I knew someone who killed himself while ago and there's nothing to laugh about, even if I am only 15 and you are older and know much more than I do, it does not give you the right to play with me.
Quote:
The problem is that things get clear while discussing it. To discuss something you need people who are able to DISCUSS, real team-players. If you don't feel like this, you will probably cause conflicts here in the (near) future.
Sorry but I discuss of the solutions and not of the problem, it is your task to know what you want us to solve. Besides, if you want me to leave, I will do, once I make sure that I cannot give to this place anything but ruination.
Quote:
lyx, take it easy man. no big deal here. don't get stressed. not good for the heart
Thanks for your regards but it has been while since I forgot the true meaning of that. ^^
[edit]Corrected some grammar mistakes.