Hacker News new | past | comments | ask | show | jobs | submit login

This is a perfect use for the C++ auto feature:

    auto x = call_returning_int();



C had this particular feature for decades.


No, and it still doesn’t.



What 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: