View Single Post
Old 08-31-2005, 06:48 PM   #10 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
In general, the type that is being compared needs to be able to be compared with the same type. For example if you would like to sort integers then at one moment a comparison is needed like:
Code:
if( FirstInt < SecondInt)
{
   //Do stuff.
}
This snippet implies that the type of FirstInt and SecondInt can be compared with eachother.
The class or type they represent needs to be a comparable class or type.

Suppose one wants to sort humans. Such a definition doesn't make much sense. The next refinement is that I may want to sort people by some sort of property they have. This looks reasonable. The whole trick is now to define a class CHuman that is comparable. The same goes for cars, houses, services and whatever you can think of.

Conclusion:
Study the ways of making comparable classes.
__________________
Valmont is offline   Reply With Quote