hello children yep, i got anouther problem with C++
ok, before any1 points this out to me, i am aware that there are header files that do what im trying to do, however im coding them myself in an attempt to learn the basics.
I am trying to make a string class which replaces all those great VB string functions ,, eg Len() Mid() UCase() LCase() Right() Left().
the problem is, that i have to declair a maximum length fro my string. to waste less memory, i have made a base class with all the functions that has the largest string [1024] and then i make loads of derived classes with only 1 difference,,,, the size of the string, so the user can use whatever class depending on wether they need to store a small name, or huge string.
here's how it works..
class CString1024
{
protected:
char m_string[1024];
public:
//loads of functions and over loaded operators
};
class CString512: public String1024
{
protected:
m_String[512]
};
as you can see, CString512 has a smaller string, but inherits all the fnctions from CString1024...
and the idea was that it only used a string array of half the size,,
BUT, testing has shown that all derived classes use the base class's size String.
How do i fix this ?
thanX
Enter your message below
Sign in or Join us (it's free).