Reputation: 47
I have a small question. Let's say I have
Character char1;
Character char2;
What's the best way to compare if all the member class variables are the same? Can I use memcmp for it? I'm kinda new to this memory stuff, so thanks everyone for help.
Upvotes: 2
Views: 627
Reputation: 66459
You can't use memcmp
.
The normal way is to write you own equality operator.
As a non-member it would look like
bool operator==(const Character& lhs, const Character& rhs)
{
return lhs.member1 == rhs.member1
&& lhs.member2 == rhs.member2
&& ...
}
Upvotes: 5