3 ms·
This is a perfect use for the C++ auto feature: auto x = call_returning_int();
by RcouF1uZ4gsC 9y ago
This is a perfect use for the C++ auto feature:
auto x = call_returning_int();
- wruza 9y agoC had this particular feature for decades.
- louiz 9y agoNo, and it still doesn’t.
- wruza 9y agoTime to explain the joke, right? https://stackoverflow.com/questions/2192547/where-is-the-c-auto-keyword-used/2192761#2192761 https://stackoverflow.com/questions/2192547/where-is-the-c-a...
- daemin 9y agoWhat he means by that is the old definition of auto, which C++11 deprecated in favour of making it do type deduction instead. auto foo = func_returning_int(); to my knowledge worked in C because 'auto' was the lifetime keyword - like 'register' - and the default type in C is 'int'. That's why when you miss a definition in C++ the compiler warns you that there's no default int.