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?

Member Avatar for stephen.id

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.

aha, stupid of me....
thanks for the help :)

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.