Re:Strange C Syntax
by seba_dos1 on Sunday August 02, 2015 @05:37PM
(#9992581)
My favorite is similar thing, but in C++ and much more confusing:
"foo.method();" doesn't compile because:
That's right: "foo" is a declared function that returns instance of Foo and takes one argument - a function that returns instance of Bar :) But when you add additional parentheses in a line above:
then "foo" is an instance of Foo created by passing a new instance of Bar to its constructor, which is more like what you'd expect by reading the code, and the code compiles. Fun!
[ Parent
| on HN ]
Re:Strange C Syntax
by BudVVeezer on Sunday August 02, 2015 @07:10PM
(#9992876)
Yes, the most vexing parse.
Re:Strange C Syntax
by bobbyi_settv on Monday August 03, 2015 @12:17PM
(#9997253)
C++11 initialization syntax solves this
https://en.wikipedia.org/wiki/Most_vexing_parse#Uniform_init...