I'm brushing up on my c++ and my compiler warning told me that I could use auto with c++14. Seems very convenient, but I was wondering if there might be a downside to not specificly stating the return type.
I'll put some code below in case my question is not clear.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
// is there a downside to using auto instead of std::string?
auto print_str()
{
auto str = "hello";
return str;
}
int main(int argc, char** argv )
{
std::cout << print_str() << "\n";
return 0;
}