0

Do I need to provide == and/or != operators? I've read here: Why don't C++ compilers define operator== and operator!=? that I do but when I actually tried it (didn't provide them and tried to use them) the program compiled fine. So what's going on?

Using VS2010 if it matters.

Community
  • 1
  • 1
NPS
  • 6,003
  • 11
  • 53
  • 90

1 Answers1

1

These operators are defined for fundamental, language-defined types, not for your custom ones. So it will work for ints, for example. But won't for class foo; unless you provide them explicitly - compiler doesn't know how to compare your own defined types if you haven't told it how to do it.

SomeWittyUsername
  • 18,025
  • 3
  • 42
  • 85