Jump to content
  • Advertisement
Sign in to follow this  
remmargorprogrammer

C++ error 'overloaded-function'

This topic is 4434 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What means this? error C2679: binary '>>': no operator found which takes a right-hand operand of type 'overloaded-function' (or there is no acceptable conversion) //declared variables: string accountNumber; char code; int gallons; double cost; int i; ifstream in; in >> accountNumber >> code >> gallons >>endl; // ERROR for this line

Share this post


Link to post
Share on other sites
Advertisement
Could it be that you are putting a >> endl?

That does not make any sence. Why are you trying to set endl?

Share this post


Link to post
Share on other sites
You can't "read into endl". It says there is "no overload for this type" because the reason you can't "read into endl" is that endl is an identifier (a global identifier in the std namespace that gets pulled in via the iostream header), not a keyword; and the type of that variable is a type X for which operator<<(istream&, X&) is not defined. It says "overloaded-function" as the type because 'endl' is actually the name of a function, rather than an ordinary variable. The ostream implementation provides for operator>>(ostream&, ostream&(*)(ostream&)&), where that second parameter refers to the type of the function pointer named by 'endl'. It could be implemented something like:


ostream& operator>>(ostream& os, ostream&(*pf)(ostream&)&) {
return pf(os);
}


That is, you can do "std::endl(std::cout);" and it would have the same effect as "std::cout << std::endl;", because that is what endl is.

Anyway, if you want to skip to the next line, look up cin.ignore() and have fun.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!