error message

This is a discussion on error message within the C++ Programming forums, part of the General Programming Boards category; Hi All am a newbie to this c++ thing so forgive if this seems a bit obvious. I tried searching ...

  1. #1
    Registered User
    Join Date
    May 2007
    Posts
    6

    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:
    Code:
            ofstream outf;
    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

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Think you need to call the constructors on those objects right away, but that's just a quick random guess.

  3. #3
    Registered User
    Join Date
    May 2007
    Posts
    6
    ouch - was hoping I wouldn't get one of those replies - thought I had done....
    will stumble on.

    jonh :-)

  4. #4
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Man, I'm not thinking clearly. That's an error from forgetting to include <fstream>.

  5. #5
    Registered User
    Join Date
    May 2007
    Posts
    6
    Ah, was just about to ask if I should be including anything other than:
    Code:
    #include <iostream>
    
    #include <string>
    will give it a try.

  6. #6
    Registered User
    Join Date
    May 2007
    Posts
    6
    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

  7. #7
    Registered User
    Join Date
    May 2007
    Posts
    6
    ps is your "do your own homework" graphic an instruction to the 'posted to '
    or is it just a graphic??

    j

  8. #8
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    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.

  9. #9
    Registered User
    Join Date
    May 2007
    Posts
    6
    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

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21