Sorry if the title is a little vague, my terminology isn't that great yet. What I'm t?rying to say is: which one is better in terms of memory management and if there is any difference Or which one is better to do in practice?
Say I have a function that will constantly update.
function update() {
int i = random();
}
Here we constantly declare 'i' as an integer and give it a random number. This update will run untill program is terminated. Is this bad to do? How does memory deal with this? I imagine it's not much on its own like that, but maybe with bigger code it could affect things?
Is it better to just declare 'i' in the class header in any way, shape or form? Like it would allocate memory only ones for 'i'?
Still need to learn a lot on memory management, obviously :)