Jan 17, 2015

[C++] temporary string + int

gcc: get warning for `std::string("foo" + 42);`?


#include <iostream>

int main()
{
    std::cout << ("hi" + 42) << std::endl;
}
a.k.a
#include <iostream>
#include <string>

int main()
{
    std::cout << 42["hi"] << std::endl;
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.