Method Compare

 

Your_Class::Compare

 

By default,  the "Compare()" method does a string compare on the content of the "Sort" string. You set the value of this string with the method "Sort_Set()", usually within the constructor.  However, if you want to use another technique to compare 2 instance of the same class, you can override this method.

 

 

Syntax

 

int Your_Class::Compare(

          SliceO_Class *pt_b

)

 

 

Parameters

 

pt_b

Pointer to the class we want to compare this class to.

 

 

Return value

 

This method return an integer value:

·< 0 if if "this" is to be placed before "pt_b",

·> 0 if this is to be placed after "pt_b",

·= 0 if both are equivalent.

 

 

Remarks

 

 

Requirements

 

Header:

          sliceO_include.hpp

 

Library:

          sliceO_Structures.lib

 

 

Example

 

The default compare method

 

// ----------------------------------------------------------------------------

//

//          Compare()

//

//          Comprae 2 frames:

//

//          param:          pt_b (SliceO_Class *)          Pointer to second node

//

//          return:          (int)                              a value < = or > 0

//

// ----------------------------------------------------------------------------

int          SliceO_Class::Compare( SliceO_Class *pt_b )

{

          return( strcmp(this->Sort_Get(), pt_b->Sort_Get()) ) ;

}

 

See also