I use the c++11 auto keyword just about everywhere. I'm not sure if I'm using it correctly in this case though. Consider the following trivial example: (http://ideone.com/TxLJlx)
#include <iostream>
const char* f()
{
return "Hello";
}
int main()
{
auto s1 = f();
auto* s2 = f();
std::cout << s1 << std::endl;
std::cout << s2 << std::endl;
return 0;
}
Both auto and auto* seem to work and appear to do the same thing. Is this assumption wrong?
Why do both give the same results?
Which is the correct use of auto in this case?