Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Nov 20, 2012, 02:16 PM   #1
stevegreen22
macrumors newbie
 
Join Date: Aug 2012
Bizarre issue!!!

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. -.-
stevegreen22 is offline   0 Reply With Quote
Old Nov 20, 2012, 04:38 PM   #2
gnasher729
macrumors G5
 
gnasher729's Avatar
 
Join Date: Nov 2005
Quote:
Originally Posted by stevegreen22 View Post
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. -.-
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.
gnasher729 is offline   0 Reply With Quote
Old Nov 20, 2012, 06:02 PM   #3
lloyddean
macrumors 6502a
 
Join Date: May 2009
Location: Des Moines, WA
Odds are 'meh.getNumberOfTracks()' is not returning an 'stream&' so there is no stream for 'endl' to do it's thing against.
lloyddean is offline   0 Reply With Quote
Old Nov 21, 2012, 12:05 AM   #4
MattMcClinch
macrumors newbie
 
Join Date: Jan 2008
Quote:
Originally Posted by lloyddean View Post
Odds are 'meh.getNumberOfTracks()' is not returning an 'stream&' so there is no stream for 'endl' to do it's thing against.
'meh.getNumberOfTracks()' doesn't need to return a stream&.
'cout << "fdsddigifg " << meh.getNumberOfTracks()' should return a stream&.
'meh.getNumberOfTracks()' should return a nonnegative integer.
MattMcClinch is offline   0 Reply With Quote
Old Nov 21, 2012, 12:43 AM   #5
lloyddean
macrumors 6502a
 
Join Date: May 2009
Location: Des Moines, WA
You're correct! Which is why one should never respond under the effect of pain.

Thanks for catching that.
lloyddean is offline   0 Reply With Quote
Old Nov 21, 2012, 12:51 AM   #6
lee1210
macrumors 68040
 
lee1210's Avatar
 
Join Date: Jan 2005
Location: Dallas, TX
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
lee1210 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 01:56 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC