I have a conversion error when I do this, what is happening?
1 2
string b = "abc";
string a = b.back();
Also I am using code block ide to do this, i was wondering if anyone knows how to start the intellisense so that when i type the 'back' I can see some brief info on this back function as a tool tip, like the data type its returning or the available parameters. This intellisense happens when I type things like 'int' or 'string', the tool tips will always appear, but not for this 'back'.
You can assign a char to a string, but string a = b.back() is trying to call a constructor, not an assignment operator. There is no constructor that takes a char, but there is this: string a(1, b.back()); // constructor string::string(size_t n, char c)
Here it is using the assignment operator:
1 2
string a, b = "abc";
a = b.back(); // assignment operator string::operator=(char)
Why didn't they design the string ctor to take the char first and the repeat factor second and have the repeat default to 1? That seems to make more sense.