- Main Page
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

# Comparable< T > Class Template Reference

Mix-in that gives its subclass a full set of comparison operators. More...

`#include <comparable.h>`

Inheritance diagram for Comparable< T >:

[legend]
List of all members.

## Public Member Functions
bool | operator== (const T &other) const
| Returns true if "other" is equal to this object.
bool | operator!= (const T &other) const
| Returns true if "other" is not equal to this object.
bool | operator< (const T &other) const
| Returns true if "other" is less than this object.
bool | operator<= (const T &other) const
| Returns true if "other" is less than or equal to this object.
bool | operator> (const T &other) const
| Returns true if "other" is greater than this object.
bool | operator>= (const T &other) const
| Returns true if "other" is greater than or equal to this object.
## Protected Member Functions
virtual | ~Comparable ()
| Destroy object.
virtual int | compare (const T &other) const =0
| Compare this object to another of the same type.

## Detailed Description

### template<class T>
class Comparable< T >

Mix-in that gives its subclass a full set of comparison operators.

Simply by inheriting publically from this and implementing compare(), the subclass gains a full set of comparison operators, because all of the operators are implemented in terms of compare().

## Constructor & Destructor Documentation

template<class T>

virtual Comparable< T >::~Comparable | ( |  | ) | `[inline, protected, virtual]`

Destroy object.

This class has nothing to destroy, but declaring the dtor virtual placates some compilers set to high warning levels. Protecting it ensures you can't delete subclasses through base class pointers, which makes no sense because this class isn't made for polymorphism. It's just a mixin.

## Member Function Documentation

template<class T>

virtual int Comparable< T >::compare | ( | const T & | other | ) | const`[protected, pure virtual]`

Compare this object to another of the same type.

Returns < 0 if this object is "before" the other, 0 of they are equal, and > 0 if this object is "after" the other.

The documentation for this class was generated from the following file:

- comparable.h