- Back to Home »
- GENERAL OR BASIC PROGRAMS , TUTORIALS IN C »
- C++ how to compare two objects of the same class
Posted by : ANIMESH SHAW
Thursday, 15 March 2012
The equality operator will work on pointers regardless of whether you've implemented the equality operator for your class. If it's giving an error when used with pointers, then you're doing something wrong.
To define the equality operator as part of your class:
Code:
class test
{
public:
bool operator==(const test &t); // in this method, see if t is equal to *this.
}

Oh my goodness! Awesome article dude! Many thanks, However I am having troubles with your RSS.
I don't know why I can't subscribe to it. Is there anybody having identical RSS problems?
Anybody who knows the answer will you kindly respond? Thanx!
!
Also visit my blog ; how to lose weight quick