Codeforces и Polygon могут быть недоступны в период с 23 мая, 7:00 (МСК) по 23 мая, 11:00 (МСК) в связи с проведением технических работ. ×

Блог пользователя 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
  • Проголосовать: не нравится