Why would I need to explicitly cast number 0 to char before appending it to string using string::operator+?
using namespace std;
int main()
{
string s = "";
s += 65; // no compile error
s += (char)0; // requires explicit cast
//s += 0; // compile error
return 0;
}
Update to clarify: My goal has been to append one byte (containing whatever value, including zero) to an existing array of bytes.
Because
s += 0is ambiguous for the following overloaded operators of +=0for the first function means a NULL terminated string with first character set to NULL, and for the second function is a single character with value set to0.