why don't c++ compilers interpretation operator== operator!=?
i am large fan permitting compiler many work possible. minute rudimentary category compiler give following 'free':
- a default (empty) constructor
- a duplicate constructor
- a destructor
- an assignment user (
operator=
)
but can't seem give any comparison operators - such operator==
operator!=
. example:
class foo
{
public:
std::string str_;
int n_;
};
foo f1; // works
foo f2(f1); // works
foo f3;
f3 = f2; // works
if (f3 == f2) // fails
{ }
if (f3 != f2) // fails
{ }
is there good reason this? since behaving member-by-member comparison problem? apparently category allocates memory following you'd wish careful, nonetheless rudimentary category definitely compiler you?
Comments
Post a Comment