slashman said:
I recently came across code that looked like this
float i = {1.0};
Can anyone tell me the significances of the curly braces{}.
There's no "assignment" in your code. This is _initialization_, not
assignment. The initializer is enclosed in '{}'. Initializers enclosed
in '{}' are normally used with aggregates. However, it is perfectly
legal to use '{}'-enclosed initializers with scalar objects, in which
case the '{}' are simply redundant. They don't mean anything, meaning
that your code is the exact equivalent of
float i = 1.0;
The ability to use '{}' in scalar initializers might be useful in
"generic" code (in macros, for example), where you can use the common '=
{ 0 }' initialization idiom with a wider range of types.