#include
#include
int main()
{
std::string test = "45";
int myint = stoi(test);
std::cout << myint << '\n';
}
or
#include
#include
using namespace std
int main()
{
string test = "45";
int myint = stoi(test);
cout << myint << '\n';
}
look at http://en.cppreference.com/w/cpp/string/basic_string/stol