I'm following a tutorial for C++ and looking at strings and overloading with operators such as +=
, ==
, !=
etc. Currently I have a simple if-statement:
if(s1 < s2)
cout << s2 <<endl;
else
if(s2 < s1)
cout << s1 << endl;
else
cout << "Equal\n";
But how does this work, and how does the program decide which string is greater than another? looking around I've found a basic template declaration:
template<class charT, class traits, class Allocator>
bool operator< ( const basic_string<charT,traits,Allocator>& lhs,
const basic_string<charT,traits,Allocator>& rhs );
Does this define how <
works? If so, what does <charT,traits,Allocator>
mean / do?
Also do the following operators have any meaning for strings? -=
and *=