Overload == for string class
Howdy,
I'm sick of !strcmpi(). I want another function that can tell me if two strings match. In fact, I'd like to use an == operator on the strings to see if they match. I remember when I used to use borland C++ Builder, and had access to AnsiString. Those were the days!
I figured I'll do it myself. I'll overload the == operator for a string class, and return true or false depending on whether the strings matched. This is what I wrote:
Code:
class PaulString : public std::string
{
public:
bool operator==(PaulString rhs)
{
if (!strcmpi(this, rhs) )
return true;
else return false;
}
}
That all seemed fine, except now it wont let me use something like:
PaulString Name = "Fred";
because theres no = operator for it. I thought that by having inherited everything from 'std::string' that I would have gotten the = operator.
If anyone can show me how this should be written (or if its possible), or show me how I can use AnsiString on MSVC6, I would be very thankful :)