Hello,

I've written couple of overloaded operators in my file containing Set declarations. I want to use these operators within the declaration file. However it seems it isn't used. Instead it uses the standard operators.


e.g. i have two overloaded operators say <= and ==

bool Set::operator<=(const Set& b) const {
   //codes....
   return true;
}

bool Set::operator==(const Set& b) const {
   if(b.header <= header && header <= header)
       //codes....
   return true;
}

Inside my overload for == which I use <= it doesn't use my overloaded version of <= instead it uses the standard version. Do I have to write a certain way to use my overloaded operator? or is it some other problems?

hmm.......i dont understand what exaclty your trying to do, please explain in a different way :P

I want to use my overloaded operator, inside another overloaded operator.

Hello,

bool Set::operator==(const Set& b) const {
   if(b.header <= header && header <= header)
       //codes....
   return true;
}

Inside my overload for == which I use <= it doesn't use my overloaded version of <= instead it uses the standard version. Do I have to write a certain way to use my overloaded operator? or is it some other problems?

Inside your operator==, you're comparing header, not Set. You'd have to have an overload for whatever type b.header is.

Edited 3 Years Ago by mike_2000_17: Fixed formatting

This question has already been answered. Start a new discussion instead.