Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
nothing.
in the first option - the declaration and assignment of value.
in the second - splitting into two operations.
any sensible compiler will lead both codes to the same thing. that is, the difference is only in readability.
https://godbolt.org will help you, it will show what the resulting code will be.
There is an ideological difference. In the second case, it is possible to add additional code between the declaration and the value assignment. If it tries to operate on an uninitialized variable, it will result in undefined behavior.
The first option does not allow such liberties, so it is recommended to use it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question