I have some issues understanding why one way of declaring and initalising a local variable is allowed and one isn't.
For example, this doesn't compile:
if ("b" == "b")
int a = 1;
Whereas, the following examples compile:
if ("b" == "b") {
int a = 1;
}
and
int a;
if ("b" == "b")
a = 1;
Can you please help me with this?
a
should be in scope even though I am not using the {
,}
brakets. If it helps, the error suggested by the compiler is: error: not a statement
- thus, it doesn't recognise int
as a statement.