1

C++ string class design and implementation

view story
linux-howto

http://www.unix.com – Hi, I am designing the look-alike C++ string class: Code: #include <iostream> #include <cstring> #include <exception> #include <new> #define ALLOC(N) (char*) new char[sizeof(char)*(N)] #define DELETE(P) delete[] ((char*)(P)) class String { public:     // conversions: to C-like type char     operator const char*() const { return _str; }     explicit String(const char* s = (char*)0) {         if (s) {             try {             &nbs (HowTos)