Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Lake43y@iiii I'm not asking how to use a constructor, I'm saying it's bad inconsistent design to have "Type(args)" mean one thing if args is empty but another if it's not. It would be similar to saying char is int8_t when used with an array of size 1, but int16_t if it's used with array of size bigger than 1.
-
atheist99833yAnd FYI, "devrant" is for rants about the app. For future reference, this would be a rant.
-
atheist99833yThis rant can be summed up as "Writes bad code. Complains code is bad."
I'll be quiet now... -
@iiii @atheist OP is actually right. This is a documented inconsistency. It's called the "most vexing parse". Look it up. The compiler is required to interpret that as a function.
How C++ *should* be used is irrelevant here - that is legitimate syntax for object construction. The syntax allows the ambiguity to exist though, so they had to arbitrarily choose of the two interpretations as default.
Related Rants
-
xjose97x19Just saw a variable in C named like this: long time_ago; //in a galaxy far away I laughed no stop.
-
Unskipp24So this happened last night... Gf: my favorite bra is not fitting me anymore Me: get a new one ? Gf: but it ...
-
Pointer19School time, programming class: Girl: Hey, Can you help me? Me: Sure, what's up? G: I have an error but I don'...
Programmer: Type type(2);
C++ Compiler: // Okay, I'll use the constructor that takes 1 argument
Programmer: Type type();
C++ Compiler: // I see there is a constructor that takes no arguments, but surely you don't want that. Everybody loves functions, a function shall be declared!
Who, in their right mind, thought this syntax is a good idea?! Syntax inconsistencies drive me crazy...
devrant
c++
syntax