bool operator >(Counter & rhs)
         {

         }

         bool operator ==(Counter & rhs)
         {

         }

         bool operator !=(Counter & rhs)

Recommended Answers

All 2 Replies

Those are overloaded binary operators. Basically you are specifying what myClass1 > myClass2 really means. For example, say you had a class that contains 2 integers, a and b. If you wanted to implement some functionality that compared the two classes (for example a greater than > operator) your computer isn't going to make any assumptions on which values to compare.


Say that you wanted the > operator to compare the member 'a' between counter classes:

bool operator >(Counter & rhs)
{
    return this.a > rhs.a
}

I'm a bit of a C++ noob/washout but this stuff is simple :P Make sure to pay attention to your teacher!

Thank you..badass..right on...simple yet so complex..if ur behind that is...but gracias my friend

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.