0

Possible Duplicate:
Operator overloading

I need to implement template class in following way

Requirement: you must provide code for implementing a sorting 'comparator' called SensibleLessThan, that is capable of sorting text strings.

and it will call in following way.

SensibleLessThan<String> comparer;
  String lhs = "Aadvark";
  String rhs = "Zygote";
  comparer(lhs, rhs);

Should I write SensibleLessThan class and create object? But they are calling comparer like function. Can anyone provide me some idea how can I accomplish this?

Please let me know if I need to provide more info.

Community
  • 1
  • 1
  • You might want to look at lexicographical sorting if you don't have that part figured out yet. That would be the one to choose. – chris May 05 '12 at 14:08

1 Answers1

2

Hint: Look up the operator(). It lets you apply the function call operator on an object.

sashang
  • 11,704
  • 6
  • 44
  • 58
  • you mean I should write conversion operator. So I need to create object and write conversion operator and pass parameter. –  May 05 '12 at 15:07
  • No, not a conversion operator. I mean you should implement a function call operator. It lets you use the object as if it is a function. – sashang May 05 '12 at 23:43