Thread: String Library
View Single Post
Old 03-15-2003, 11:04 AM   #11 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Quote:
I think awhile back I toyed with my string libraries for a class...
Toying with the standard library is (conceptual) not a good idea anyway.

Next time when you have the urge to "toy" with the standard library, just derrive a class from your lib of interest.
Note that all the methods in the original lib are virtual. So you can override all the methods in your new class to shape it like you wish.

EXAMPLE:

// test_CmyString.cpp

#include <string>
using namespace std;


//First we make our experimental class, derrived
//from the original string library.


class CmyString : public string
{

/* Implement here your experiments.
Note that all the methods are inherited by CmyString, so you
still use them. And you can add your own insights like new
methods and properties to make a "better" string class.
Make sure you are familiar with the basics of inherritance
before you start with this.
*/

};

int main ()
{

// You can use here your new invention
return 0;
}
Valmont is offline   Reply With Quote