error: variable ‘std::stringstream ss’ has initializer but incomplete type



  • Folgenden Code habe ich aus dem Netz kopiert und in mein Programm eingefügt:

    #include <strstream>
    ...
    int DataExtractor::str2int(const string &str) {
    	stringstream ss(str);
    	int num = -1;
    	if((ss >> num).fail())
    		cout << "Error parsing " << str << " to int " << endl;
    	return num;
    }
    

    Wenn ich das kompiliere, dann erhalte ich folgenden Fehler:

    g++ -g -Wall -c DataExtractor.cpp -o DataExtractor.o
    In file included from /usr/include/c++/4.0.0/backward/strstream:51,
    from DataExtractor.cpp:5:
    /usr/include/c++/4.0.0/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
    DataExtractor.cpp: In member function ‘int DataExtractor::str2int(const std::string&)’:
    DataExtractor.cpp:27: error: variable ‘std::stringstream ss’ has initializer but incomplete type
    make: *** [DataExtractor.o] Error 1

    Das versteh ich leider nicht 😞



  • Stringstream ist in sstream definiert.



  • 😃 Danke, danke... 🙄


Anmelden zum Antworten