4 ms·
Wait - are we talking C/C++ here? where a function call, a variable declaration, an expression cast all look identical?
by JoeAltmaier 11y ago
Wait - are we talking C/C++ here? where a function call, a variable declaration, an expression cast all look identical?
- spdionis 11y agoNo, C/C++ have bad syntax too, imo.
- mbel 11y agoYou are probably talking about C++, not C, unless those look identical to you: foo(); int foo; (int)foo;
- JoeAltmaier 11y agothe cast can equally be int(foo); or (int)(foo); The parenthesis are allowed and optional. The method can be declared (int) foo(int(x), int(y)); which can also be an invocation. etc.
- therealdtscode 11y agoI wouldn't really say they are optional. The two do different things. (int) foo (or (int)(foo)) is a c-style cast. int(foo) isn't a cast. Instead it invokes the int constructor with the argument foo.
- mbel 11y agoint(foo) and (int) foo(int(x), int(y)) are not legal syntax in C. However, they are in C++ [0], which is my whole point. [0] your method declaration has a small problem, it apparently cannot have parenthesis around returned type.