I came up with the idea to define a generic comparison operator which would work with any type, for the fun of it.
#include
#include
Let's take a perfectly normal class, say String
. It's implemented as you'd think, with a char*
that points to a new[]
'ed buffer.
Now compare two of them. Obviously, String("abc")==String("abc")
. Yet your implementation fails this test, as the two pointers differ.
Equality is defined by the class semantics, not by the bits directly inside the object.