Блог пользователя immadmohit

Автор immadmohit, история, 3 года назад, По-английски

Hello, I actually searched this issue on google and got one answer on stack overflow but was not able to understand it well, Can someone explain to me why am I getting this error.

string convert(string name)
{
  string code = name[0];
  ...
}

I am getting "no viable conversion from 'value_type' (as of 'char') to 'string' (as of 'basic_string, allocator >')" from this line.

But if I will change this code to this:

string convert(string name)
{
  string code;
  code = name[0];
  ...
}

Then it will work fine. Thanks in advance.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +11
  • Проголосовать: не нравится