There is some difference between the two statements:
First:
int a;
int b;
Second:
int a, b;
Which is better? Do variables get closer in memory or is this just myth? Is there any significant difference?
There is some difference between the two statements:
First:
int a;
int b;
Second:
int a, b;
Which is better? Do variables get closer in memory or is this just myth? Is there any significant difference?
No, zero, this is just a form of syntax. Once compiled it's all the same. In general all these different forms of syntax do not change anything. There may be when there is semantic difference, which is not the case, there is no such thing as getting closer in memory, you have no control of it and even if it does not make a difference because the memory is accessed directly and changes nothing where it is (in general, there are a lot more complex cases that this can change, but it's something very advanced even, not for simple things like that.Note that it has no context in the question.It makes more difference for the context used than this in itself.Not this , but it makes a difference if this is a local variable or member of an object, not that it matters so much the variable in this case.
So it's important to understand every detail of the code. I use this phrase in my lectures:
In terms of performance does not change anything, if you are doing the program alone does not change anything either. If you are developing software as an employee of a company or in a team, use the form that the company or team decided to standardize as it facilitates the indentation and reading of the code. Try to have general notions of how a compiler works, knowing how software compiles will make you a better programmer.