-
error message
Hi All
am a newbie to this c++ thing so forgive if this seems a bit obvious.
I tried searching but to no avail....
I am getting a weird error in one of my tutorial programs. A simple effort to write data to a file.
The error says:
write.cpp: In function ‘int main()’:
write.cpp:5: error: aggregate ‘std::ostringstream strbuf’ has incomplete type and cannot be defined
write.cpp:19: error: aggregate ‘std::ofstream outf’ has incomplete type and cannot be defined
line 5 is;
Code:
ostringstream strbuf;
and
line 19 is: they seem pretty straight forward lines to me.
any idea what this incomplete type thing is?
I've tried compiling on windows and linux but get the same error.
any help greatly appreciated
john
-
Think you need to call the constructors on those objects right away, but that's just a quick random guess.
-
ouch - was hoping I wouldn't get one of those replies - thought I had done....
will stumble on.
jonh :-)
-
Man, I'm not thinking clearly. That's an error from forgetting to include <fstream>.
-
Ah, was just about to ask if I should be including anything other than:
Code:
#include <iostream>
#include <string>
will give it a try.
-
it got rid of the second error. So am guessing that something like <stringstream> should be included for the other one, or similar...
In fact <sstream> seemed to do it. Compiles fine now.
nice one
many thanks
john
-
ps is your "do your own homework" graphic an instruction to the 'posted to '
or is it just a graphic??
j
-
Just a signature I keep on for the many requests by lots of different people here to complete homework assignments.
It was not directed at you. :)
Congrats at getting it working.
-
cheers
have worked in other languages before but not in c++, its gonna take a bit to get the layout right.
Appreciate the sentiment of the graphic though, tis easy to just to try get someone else to do it for ya.
onto the next bit now.
j