November 2001
Beginner
1128 pages
29h 12m
English
The string class offers methods and functions for comparing two strings. First, here are the method prototypes:
int compare(const basic_string& str) const;
int compare(size_type pos1, size_type n1,
const basic_string& str) const;
int compare(size_type pos1, size_type n1,
const basic_string& str,
size_type pos2, size_type n2) const;
int compare(const charT* s) const;
int compare(size_type pos1, size_type n1,
const charT* s, size_type n2 = npos) const;
These methods use a traits::compare() method defined for the particular character type used for the string. The first method returns a value less than 0 if the first string precedes the second string according to the ordering supplied by traits::compare(). It returns ...
Read now
Unlock full access