On Sat, 13 Jun 2015 10:35:13 -0700 (PDT), Paul <
peps...@gmail.com>
wrote:
>A C++ textbook says "The string library lets us convert both character literals and character string literals to strings"
>
>I don't think I'm included in this "us" because std::string s = 's'; isn't accepted by my compiler. Is this yet another textbook error?
You are trying to do it as initialization. To do that, you need to use
the "fill" form of the constructor since there is no other char form
(see
www.cplusplus.com/reference/string/string/string/):
std::string s (1,'s');
The operator= has a char form. The conversion works for assignment,
as in:
std::string s;
s = 'x';
--
Remove del for email