Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 27th, 2006, 4:25 PM   #1
sackarias
Programmer
 
sackarias's Avatar
 
Join Date: Jan 2006
Posts: 58
Rep Power: 3 sackarias is on a distinguished road
while loop question

while ( src >> word){ //code };

In this case, does (src >> word) actually do my overload for >>? Or does it just check if it's possible, then enter the loop?

I hope that makes sense...!!

Thanks!
sackarias is offline   Reply With Quote
Old Mar 27th, 2006, 4:37 PM   #2
bgeraghty
Newbie
 
Join Date: Mar 2006
Posts: 15
Rep Power: 0 bgeraghty is on a distinguished road
while loops don't check if things are possible, they evaluate whether or not they are true.
bgeraghty is offline   Reply With Quote
Old Mar 27th, 2006, 4:51 PM   #3
sackarias
Programmer
 
sackarias's Avatar
 
Join Date: Jan 2006
Posts: 58
Rep Power: 3 sackarias is on a distinguished road
That's what I meant by if it's possible. The way I said it was ambiguous.
sackarias is offline   Reply With Quote
Old Mar 27th, 2006, 5:29 PM   #4
Navid
Hobbyist Programmer
 
Navid's Avatar
 
Join Date: Feb 2005
Location: Canada
Posts: 187
Rep Power: 4 Navid is on a distinguished road
Send a message via MSN to Navid
Yes, it will perform the operations in the brackets.
Navid is offline   Reply With Quote
Old Mar 27th, 2006, 5:36 PM   #5
sackarias
Programmer
 
sackarias's Avatar
 
Join Date: Jan 2006
Posts: 58
Rep Power: 3 sackarias is on a distinguished road
Thanks.
sackarias is offline   Reply With Quote
Old Mar 27th, 2006, 5:39 PM   #6
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Yes? Depends on what the insertion operator (which the OP says is overloaded) has been written to return. That's not an item of information given in the post.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Mar 27th, 2006, 5:45 PM   #7
Navid
Hobbyist Programmer
 
Navid's Avatar
 
Join Date: Feb 2005
Location: Canada
Posts: 187
Rep Power: 4 Navid is on a distinguished road
Send a message via MSN to Navid
It performs what ever it’s instructed to in the brackets. Whether it continues into the braces depends on the return value as DaWei said. Unless I’m wrong again.
Navid is offline   Reply With Quote
Old Mar 27th, 2006, 6:15 PM   #8
sackarias
Programmer
 
sackarias's Avatar
 
Join Date: Jan 2006
Posts: 58
Rep Power: 3 sackarias is on a distinguished road
ifstream& operator>>(ifstream& fin, const WordData &curWordData);

Returns fin.
sackarias is offline   Reply With Quote
Old Mar 27th, 2006, 7:07 PM   #9
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
The insertion operator typically returns the stream (a reference). Even if insertion fails, the return will not be zero unless the function is specifically written to do that. Failures are tested with other methods (e.g., good (), eof (), fail (), etc.).
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Mar 27th, 2006, 7:16 PM   #10
PPoA
Programmer
 
PPoA's Avatar
 
Join Date: Mar 2006
Location: Tennessee
Posts: 41
Rep Power: 0 PPoA is on a distinguished road
I think he was asking if the code as written actually does the overloading. Answer to that is, no. You have to write it into a function how you want it overloaded.
PPoA is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:42 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC