#include <iostream>
#include <string>
using namespace std;
int str_to_int(string stroka){
int y, minys = 1 , ves = 1, val = 0;
for (int i = stroka.length() - 1 ; i >= 0 ; i--)
{
switch (stroka[i]){
case('+'): i--;
break;
case('-'): minys *=-1;
i--;
break;
default:
y = (int)stroka[i] - 48;
val = y * ves + val;
ves = ves * 10;
break;
;
}
}
val *= minys;
return val;
}
string int_to_str(int chislo){
string result;
int ostatok, ves = 10;
if (chislo < 0) {chislo *= -1; result += '-';};
while (chislo){
ostatok = chislo % ves;
result += char(ostatok);
}
return result;
}
int main()
{
string s, output_str;
int output_int;
cout << "input string: ";
cin >> s;
output_int = str_to_int(s);
cout << "output integer: " <<output_int << endl;
output_int=int_to_str(output_int);
cout << "output stroka: " <<output_str << endl;
}
вот ошибка:
||=== Build: Debug in seven (compiler: GNU GCC Compiler) ===|
C:\c++\seven\main.cpp||In function 'int main()':|
C:\c++\seven\main.cpp|47|error: cannot convert 'std::__cxx11::string {aka std::__cxx11::basic_string}' to 'int' in assignment|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
помогите исправить и объясните суть проблемы, пожалуйста.