G
Gunnar G
Hello.
I use the standard C++ string and I'm very pleased with it, but it lack some
functions that I need, like reverse (reverse the string), uppercase, and a
few others. Now I would like to add these functions to string. How do I do
that?
As I see it, I have at least these options:
1) write functions like void reverse(string& s)
2) write my own string class
class mystring{
public:
// stuff..
void reverse(); // or something like that
private:
string _str;
}
As see it, the only loss with alternative 1 is that can't write things like
somestring.reverse(); but I have to write reverse(somestring);
With alternative 2, I have to write everything myself, or can I inherit the
string class in some way so I don't have to write so much code, just adding
the few extra functions?
The over-optimistic solution would perhaps be to
3) modify the string.cpp/string.h files in my system.
4) write a letter to the C++ standardisation organisation
Any thoughts on this before I decide that alternative 1) is the easiest?
I use the standard C++ string and I'm very pleased with it, but it lack some
functions that I need, like reverse (reverse the string), uppercase, and a
few others. Now I would like to add these functions to string. How do I do
that?
As I see it, I have at least these options:
1) write functions like void reverse(string& s)
2) write my own string class
class mystring{
public:
// stuff..
void reverse(); // or something like that
private:
string _str;
}
As see it, the only loss with alternative 1 is that can't write things like
somestring.reverse(); but I have to write reverse(somestring);
With alternative 2, I have to write everything myself, or can I inherit the
string class in some way so I don't have to write so much code, just adding
the few extra functions?
The over-optimistic solution would perhaps be to
3) modify the string.cpp/string.h files in my system.
4) write a letter to the C++ standardisation organisation
Any thoughts on this before I decide that alternative 1) is the easiest?