共用方式為


CompareElements

Called directly by CList::Find and indirectly by CMap::Lookup and CMap::operator [].

template<class TYPE, class ARG_TYPE> 
BOOL AFXAPI CompareElements(
   const TYPE* pElement1,
   const ARG_TYPE* pElement2 
);

Parameters

  • TYPE
    The type of the first element to be compared.

  • pElement1
    Pointer to the first element to be compared.

  • ARG_TYPE
    The type of the second element to be compared.

  • pElement2
    Pointer to the second element to be compared.

Return Value

Nonzero if the object pointed to by pElement1 is equal to the object pointed to by pElement2; otherwise 0.

Remarks

The CMap calls use the CMap template parameters KEY and ARG_KEY.

The default implementation returns the result of the comparison of *pElement1 and *pElement2. Override this function so that it compares the elements in a way that is appropriate for your application.

The C++ language defines the comparison operator (==) for simple types (char, int, float, and so on) but does not define a comparison operator for classes and structures. If you want to use CompareElements or to instantiate one of the collection classes that uses it, you must either define the comparison operator or overload CompareElements with a version that returns appropriate values.

Requirements

Header: afxtempl.h

See Also

Reference

CList Class

CMap Class

Concepts

MFC Macros and Globals