Are == and != operators compiler

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.


These operators are defined for fundamental, language-defined types, not for your custom ones. So it will work for int s, 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.

链接地址: http://www.djcxy.com/p/73784.html

上一篇: 只有具有显式构造函数的类的对象的平等检查

下一篇: 是==和!=运算符编译器