I recently came across this construct: int(m); which seems to be equivalent to: int m;
Oddly, I have never seen this particular idiom before. Can someone point me to a reference where I can read the spec on this, or just explain directly? Does this also work in straight C?
Thanks, ConfusedDeveloper
It is not an "idiom". It is just a redundant pair of parentheses. Grammatically, they can be there, but they serve no purpose.
Sometimes similar seemingly superfluous parentheses can be used to resolve ambiguity in C++ declarations, like
int a(int());
which declares a function can be turned into
int a((int()));
which is equivalent to
int a = int();
and defines a variable. But this is not exactly what you have in your case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With