iostream string to int conversion


My function looks as this:
173
174
175
176
177
bool gotInteger(const string& str, int& i)
{
   istringstream ss(str);
   return ss >> i ? true : false ;
}


The error:

../a.cpp: In function 'bool gotInteger(const std::string&, int&)':
../a.cpp:175: error: variable 'std::istringstream ss' has initializer but incomplete type.


I have no idea what that means and it doesn't suggest the type I need to use, I tried adding .c_str() to str on line 175 but that didn't help.
Last edited on
Did you #include <sstream> ?
DOH!
dammit I even looked it up, thought it was part of iostream. :P
http://www.cplusplus.com/reference/iostream/istringstream/

edit: ooo, just noticed the class is shown in the top far right hand side either side of the divider.
Last edited on
Topic archived. No new replies allowed.