template < typename T > class BString {
protected:
std::allocator < T > _Buf;
Uint32 Length;
public:
BString operator += ( LPSTR Text );
BString operator += ( LPCSTR Text );
BString operator += ( LPWSTR Text );
BString operator += ( LPCWSTR Text );
BString operator *= ( Uint32 Count );
};
class StringW : protected BString < wchar_t > {
public:
StringW ( LPSTR Text );
StringW ( LPCSTR Text );
StringW ( LPWSTR Text );
StringW ( LPCWSTR Text );
voidoperator= ( LPSTR Text );
voidoperator= ( LPCSTR Text );
voidoperator= ( LPWSTR Text );
voidoperator= ( LPCWSTR Text );
wchar_t* operator[] ( unsignedint Pos );
};
class StringA : protected BString < char > {
public:
StringA ( LPSTR Text );
StringA ( LPCSTR Text );
StringA ( LPWSTR Text );
StringA ( LPCWSTR Text );
voidoperator= ( LPSTR Text );
voidoperator= ( LPCSTR Text );
voidoperator= ( LPWSTR Text );
voidoperator= ( LPCWSTR Text );
};
In the above code, I have the base class BString and derived classes StringA and StringW. I know that I can't define template methods from outside of its file, but I'll define them later. I al.so realize that the return types for the overloaded += operator is incorrect, but that's a part of my second question
My first question is if I did the inheritance right, but I'm pretty sure I have.
Then my second question is: How should I set up the return values for the overloaded operator +=? Is it possible to keep them in the base class, or do I have to now declare them in the derived classes now?
If it means that I can still overload the assignment operator and create a constructor for each one individually, then yes. How would I go about doing this? But then that still leaves the obvious question of: how would I go about doing it?
EDIT:
Alright, nevermind, forget this. I forgot all about the basic_string class, and I'm just going to use that and create my own typedefs for them.