![]() |
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! |
while loops don't check if things are possible, they evaluate whether or not they are true.
|
That's what I meant by if it's possible. The way I said it was ambiguous.
|
Yes, it will perform the operations in the brackets.
|
Thanks.
|
Yes? :confused: 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.
|
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.
|
ifstream& operator>>(ifstream& fin, const WordData &curWordData);
Returns fin. |
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.).
|
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.
|
| All times are GMT -5. The time now is 5:13 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC