Bizarre issue!!!

Discussion in 'Mac Programming' started by stevegreen22, Nov 20, 2012.

  1. macrumors newbie

    Joined:
    Aug 7, 2012
    #1
    Hey guys.

    Can someone perhaps help explain this issue I'm having?

    Essentially I get an error whenever I add an endl or a out stream to another.

    For example:

    Code:
          cout << ac.getSizeOfCollection(); 
    Works fine but....
    Code:
          cout << ac.getSizeOfCollection() << " Size" <<endl;  
    Doesn't

    I have the same issue with this:

    Code:
                cout << "fdsddigifg " << meh.getNumberOfTracks();
    //
                
    Works fine but the one below doesn't
    Code:
                cout << "fdsddigifg " << meh.getNumberOfTracks() <<" Tracks"<<endl;
    //
                
    Any ideas or suggestions? I've tried to trace back the outstream as it's overloaded and every step of the way it's fine. I simply don't understand it. -.-
     
  2. macrumors G5

    gnasher729

    Joined:
    Nov 25, 2005
    #2
    Try if std::endl makes a difference. Because std::endl is the end of line marker, and endl could be anything. If you added a variable "int endl;" at the beginning of a function that would produce some rather funny results. BTW. Once your programs get larger, you will very much prefer std::cout to cout because it provides a lot more information when you read code.
     
  3. macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #3
    Odds are 'meh.getNumberOfTracks()' is not returning an 'stream&' so there is no stream for 'endl' to do it's thing against.
     
  4. macrumors newbie

    Joined:
    Jan 24, 2008
    #4
    'meh.getNumberOfTracks()' doesn't need to return a stream&.
    'cout << "fdsddigifg " << meh.getNumberOfTracks()' should return a stream&.
    'meh.getNumberOfTracks()' should return a nonnegative integer.
     
  5. macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #5
    You're correct! Which is why one should never respond under the effect of pain.

    Thanks for catching that.
     
  6. macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #6
    We don't have enough info. meh.GetNumberOfTracks()... What does it return? Did you write the operator<< method to handle this? How about ac.getSizeOfCollection? Can you output ANYTHING after one of these? Is the problem just endl? What is the problem? A compiler error? What is it? A runtime error? Incorrect results?

    -Lee
     

Share This Page