Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

aggregate 'std::stringstream out' has incomplete type and cannot be defined [C++] [closed]

I am new to c++ please help me figure out what is wrong with this

string c;
stringstream out; //aggregate 'std::stringstream out' has incomplete type and cannot be //defined
out << it->second;
out << end1;//'end1' was not declared in this scope
c = out.str();
like image 944
Technupe Avatar asked Apr 21 '11 20:04

Technupe


2 Answers

Did you:

#include <sstream>

Also, the second to last line should be endl (nb: lower-case L) not end1 (number one).

The code below compiles and works correctly with G++ 4.2.1 on MacOS X

#include <iostream>
#include <sstream>

int main() {
        std::stringstream out;
        out << "foo" << std::endl;
        std::string c = out.str();
        std::cout << c;
}

Omitting the #include <sstream> causes exactly the same error on my system as your first error.

like image 199
Alnitak Avatar answered Oct 01 '22 19:10

Alnitak


It's an lowercase L and not 1:

out << endl;

I think @Bo is right, (sorry and thanks) change it to std::stringstream out;

like image 41
karlphillip Avatar answered Oct 01 '22 20:10

karlphillip