Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


custom types in loop statements

This topic is 6086 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

for some reason i cant compare two sockaddr_in structs in a loop statement. my code looks a bit like this: if (addr1.sin_addr == addr2.sin_addr) // do some code here when i try compiling it, it gives me 13 main.cpp no match for `in_addr & == in_addr &'' how would i go about solving this problem?

Share this post

Link to post
Share on other sites
You are actually trying to compare two objects of type in_addr. You need to compare each individual element of the struct, preferably by creating a function that performs the comparison. Since you are using C++, you can create an operator==() which does this for you.

It would look like this:

bool operator==( const in_addr& lhs, const in_addr& rhs )
// do comparison

return true
return false;

Your compiler is complaining about the fact you are trying to use such an operator when one doesn''t exist.


The placement of a donkey''s eyes in its head enables it to see all four feet at all times.

Share this post

Link to post
Share on other sites

  • 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!