#include <string> int main() { std::string a(); a="alskdfjasdj"; return 0; } output: test.cpp: In function int main(): test.cpp:6: error: assignment of function std::string a() test.cpp:6: error: cannot convert const char [12] to std::string ()() in assignment #include <string> int main() { std::string a(""); a="alskdfjasdj"; return 0; } This compiles. My understanding is that std::string a() and std::string a("") should have exactly the same result, such that the assignment of the c-string should be valid in both situations.
I neglected to comment that the command line was: g++ test.cpp
std::string a(); This declares a function that returns std::string. This is what the C++ standard says how to resolve this ambigous statement.