Answer the question
In order to leave comments, you need to log in
Overloading logical operators?
Tell me, is it possible to implicitly overload all logical operators?
class Product{
private:
int price;
string name;
public:
friend bool operator >(Product a, Product b){
return a.price > b.price;
}
};
friend bool operator ==(Product a, Product b){
return a.price == b.price;
}
Answer the question
In order to leave comments, you need to log in
you can only define 2 operators < and == , and use namespace std::rel_ops
which has definitions of operators != , > , <= , >= . It?
Take a look at boost/operators.hpp, by the way, maybe this is what you need? It's like std::rel_ops, only much more powerful.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question