0

I'm trying to use a stringstream to read in a string and convert it to various other data types. However, I keep getting the error "Incomplete data type not allowed."

My research on this error has turned up precisely two fixes: make sure to include the header, and use std::stringstream instead of stringstream. Neither of those fixes helped me. Any ideas?

#include <sstream>

bool Arena::addFighter(string info){
    std::stringstream ss;
    ss.getline(info);
    ...
}

Edit: The getline() is not the problem. The code is throwing errors when I try to declare the ss object.

Michael
  • 3
  • 4

1 Answers1

2

Change this

ss.getline(info);

to this

getline(ss, info);

Check this question for how to use getline(). Also check the ref before asking next time. :)

The error I got was this:

error: no matching function for call to ‘std::basic_stringstream<char>::getline(std::string&)’
     ss.getline(info);

If you are not using namespace std, then you should pass a std::string as an argument and not just a string.

Community
  • 1
  • 1
gsamaras
  • 71,951
  • 46
  • 188
  • 305
  • That didn't change anything in my code. The error is occurring in the declaration of the ss object. – Michael Jan 24 '15 at 21:20
  • I am using namespace std. The reason I put that in front of the stringstream was because that was the answer given to some other people getting the same error. It didn't help my code at all. – Michael Jan 24 '15 at 22:59
  • Then @Michael, you should post some more code, a minimal example. – gsamaras Jan 24 '15 at 23:19
  • I solved my own problem. Before I included , I included a header that defined a class. In that header, I forgot a semicolon at the end. (The error message for that was hidden in a whole bunch of other stuff.) Because of that, my build wasn't actually including . Thanks for the help, everyone. – Michael Jan 25 '15 at 03:50