using stream&

This is a discussion on using stream& within the C++ Programming forums, part of the General Programming Boards category; Here is what I am doing: Code: bool report(stream&,bool,int,int,int); The problem I am getting with this code is related to ...

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    15

    using stream&

    Here is what I am doing:

    Code:
    bool report(stream&,bool,int,int,int);
    The problem I am getting with this code is related to the "stream&" I am using. For this I want to be able to get a stream and be able to write with it. I want to use just stream& because that will allow me to also use the cout command as well. I want to be able to write to a file as well as use cout for testing.

    The Error I am getting is:

    Code:
    20  expected `;' before '(' token
    Does anyone have any ideas here?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,668
    > 20 expected `;' before '(' token
    Maybe look for a missing ; on the previous few lines?

    Missing one off the end of a class declaration is one common thing people do.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    15
    Quote Originally Posted by Salem
    Maybe look for a missing ; on the previous few lines?

    Missing one off the end of a class declaration is one common thing people do.
    I checked that and there is nothing else wrong. I also just commented out those 2 lines of code and the program compiled just fine. So, it has something to do with those lines.

  4. #4
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,510
    Show us the few previous line of code before that function declaration.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    7,340
    There is no such class as stream, is there? Did you mean ostream (or rather std::ostream)? If you want to write out to cout and to a filestream, ostream is what you want.

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,668
    Yeah, I thought that stream was always qualified with i, o, io, f, etc etc
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User
    Join Date
    Oct 2006
    Posts
    15
    Quote Originally Posted by Salem
    Yeah, I thought that stream was always qualified with i, o, io, f, etc etc

    Yes. I looked into it more and I am not using ostream. Thanks for the help.

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