R
Ray
Hi all,
I am thinking of subclassing the standard string class so I can do
something like:
mystring str;
....
str.toLower ();
A quick search on this newsgroup has found messages by others
suggesting that subclassing a standard class is a bad idea, especially
for beginners...
Can someone suggest what is the recommended way to add functionality
to (say) the string class? Actually, I would like to do other things
to strings, and toLower is just one of them. Is it better or is the
only way to just perform a function call:
toLower (string s)
[Of course, there is a C function with the same name, so something
similar to it.]
Another way is to create a class with a private member variable "data"
of type string I should add that I'm somewhat motivated by efficiency
as these tasks with strings will be performed very often.
Which of these two is recommended? Or is there a third that I have
not thought of?
Thank you!
Ray
I am thinking of subclassing the standard string class so I can do
something like:
mystring str;
....
str.toLower ();
A quick search on this newsgroup has found messages by others
suggesting that subclassing a standard class is a bad idea, especially
for beginners...
Can someone suggest what is the recommended way to add functionality
to (say) the string class? Actually, I would like to do other things
to strings, and toLower is just one of them. Is it better or is the
only way to just perform a function call:
toLower (string s)
[Of course, there is a C function with the same name, so something
similar to it.]
Another way is to create a class with a private member variable "data"
of type string I should add that I'm somewhat motivated by efficiency
as these tasks with strings will be performed very often.
Which of these two is recommended? Or is there a third that I have
not thought of?
Thank you!
Ray