operator overloading

Hello everybody!

I have a problem with operators! What can I do if I want to use the same operator for different procedures, for example I want to compare two classes by different factors:
1
2
3
4
5
6
7
8
class student {
 private:
   string name;
   float avg;
  public:
   student &operator < (const student &) const; // by name (alphabetically)
   student &operetor < (const student &) const; // by their average 
}


Thanks in advance!
Last edited on
don't use operators but use some other functions/functors. STL allows you to do that
Or add some static members which causes operator< to act differently depending on its value
Topic archived. No new replies allowed.