Just trying to clarify my thoughts here. Here's my current understanding.
part 1:
Declaration vs initialization...
My understanding is that you can declare a variable without giving it a value and doing so is called declaring an uninitialized variable?
eg.
int var;
Declares int var without initializing it. Correct?
Whereas declaring a variable with a value we would say we're initializing this variable with the value {v}...
int var = 0;
- Yes? No? Something totally different?
part 2:
Also if you're not going to give it a value why declare it at all? I see this all the time but I don't know if there's a reason to do it this way as opposed to assigning a value when you create it. Is it idiomatic or aesthetic preference or is there a reason? If there's a reason, should you ALWAYS do it this way? What's the time and the place and limitations?
eg.
I often see this...
int var;
var = 0;
Why not just do this?...
int var = 0;
Thanks in advance :)