Assuming you are using the std::string
implementation, a quick look the relevant functions in the C++ reference can help you understand this behaviour.
- Is the
string()
constructor called for a nameless temporary object?
- What is the datatype of this object?
Calling the constructor string()
with no arguments
Constructs an empty string, with a length of zero characters.
therefore the datatype of the given object will be of type std::string
.
- Logically, how can I concatenate a char to this object to get a string?
You concatenate as if you would to any string, trough the +
operator, which is overloaded to work with a string object as the left hand side operand, and a character as the right hand one.