Need help : No Viable Conversion

Правка en1, от immadmohit, 2021-08-09 11:16:21

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.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский immadmohit 2021-08-09 11:16:21 613 Initial revision (published)