Extending the Functionality of strings

The standard string class has been satisfactory for the uses we've made of it so far, but at this point we need some functionality that is not present in that class, namely, the ability to compare and search for portions of strings without regard to the case of the text involved. For example, we want to be able to consider “Steve” and “steve” equal, even though their ASCII code sequences differ. For another example, we want to be able to determine whether the character sequence “red” is present in a string, regardless of whether it is capitalized.

Susan had a question about why we need to do this:

Susan: Why isn't this already in the standard string class? We can't be the only ones who want to do this.

Steve: I'm not sure, other than the C++ philosophy of providing only those tools that can't be constructed from other tools. As you'll see, there are a number of ways to implement this new functionality using the existing facilities of the standard library and of C++. So I guess the library implementers figured that we could do it ourselves.

Now that we know what functionality we need to add, how do we implement this?

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset