
-----------------------------------
wtd
Wed Aug 04, 2004 10:23 pm

[C++] Why use the STL?  A quick example
-----------------------------------
So, let's say you want to remove all bad characters (to be defined) from a string.  First we'll look at the problem solved without the STL, then taking advantage of it.

For both examples we'll want a function which can test to see if a character matches what we'll consider a "bad" character.  

bool bad_char(char source)
{
   // return true if the character is the letter o.
   return (source == 'o');
} 

Now, without the STL:

#include 
#include 
#include 

bool bad_char(char source)
{
   // return true if the character is the letter o.
   return (source == 'o');
}

int main()
{
   std::string original_string = "Hello world";
   std::stringstream new_string_buffer;

   for (int i = 0; i < original_string.length(); i++)
   {
      if (!bad_char(original_string[i]))
      {
		  new_string_buffer 