Problem about function stoi() for convert a string
Hi, I have a problem with the following lines of code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
friend ifstream& operator>>( ifstream& input, Publicazioni& obj)
{
std::string::size_type sz;
string buffer;
getline(input,buffer);
if(obj.titolo!=0) delete(obj.titolo);
obj.titolo=new char[buffer.length()+1];
strcpy(obj.titolo,buffer.c_str());
getline(input,buffer);
if(obj.autore!=0) delete(obj.autore);
obj.autore=new char[buffer.length()+1];
strcpy(obj.autore,buffer.c_str());
getline(input,buffer);
if(obj.casa_editrice!=0) delete(obj.casa_editrice);
obj.casa_editrice=new char[buffer.length()+1];
strcpy(obj.casa_editrice,buffer.c_str());
getline(input,buffer);
obj.numero=stoi(buffer,&sz);
getline(input,buffer);
obj.anno=stoi(buffer,&sz);
getline(input,buffer);
obj.pagine=stoi(buffer,&sz);
return input;
}
|
The compiler give me this error:"stoi was not declared in this scope.
In the Head of the program I have called the following libraries:
1 2 3 4 5
|
#include<iostream>
#include<cstring>
#include<string>
#include<stdlib.h>
#include<fstream>
|
although stoi is a function of <string>,why does the compiler give me a mistake?
Thank you in advance.
it's a C++11 function, try compiling w/ -std=c++11 or possibly -std=c++0x
Topic archived. No new replies allowed.