Quote Originally Posted by cpjust View Post
If a function can do its job the same (or better) as a free function, then it shouldn't be a member function.
Lets take your example of ToUpper(). If it's a member function, it can only convert that particular class to upper-case. So if you have several different string classes, or even char* strings, you need to write several different ToUpper() functions. If you had a general ToUpper() free function, any class (which implements some type of iterators) or even char* strings could all use that one function.
Yeah, I've learned this much.

That would save a lot of time not having to re-invent the wheel, even if it's just re-wrapping the wheel.
I consider it a convenience. Something that makes it better if I have time to do it!
I mean, it adds extra time, so call it "free time stuff" - things you can do if you really have time or want to. It doesn't add anything to the project.

I found a class at work with over 150 member functions & 120 member variables!!! Worse yet, there was absolutely no documentation about what any of it does... So trying to modify it is a nightmare. Don't make the same mistake as they made, otherwise the developer that has to inherit your code will curse your name until the end of time.
I see that as a problem with the documentation. Obviously they didn't document it good enough! You could run into the same problem if the free functions weren't documented either!
The thing is... if they documented it properly, then that class would be easier to use than free functions (or at least for me), although modifying it might be another matter...

BTW Elysia, don't you ever sleep? I see you posting 24 hours a day!
I do sleep... But generally I do also have access to a computer where I go! It keeps me from getting bored

Quote Originally Posted by citizen View Post
std::basic string has like 107 member functions, maybe Elysia should use that. It recoded a bunch of algorithms as member functions, too. I think Elysia will be very happy with the decisions in the design.
I don't think so.
Std::string is one of the most unhelpful string classes I've seen. Replace is fatefully misnamed.
Find_first_of, for example, is also inappropriate named. It should be named more similarly to find_any_first_of or the like since it finds any of the characters in the string, not the entire phrase.
The replace function is misleading into believing it can search and replace a given occurrence of a string with another. Further, it does not reallocate or move data (I think?), so if you replace "Alice" with "Jonathan" you're going to overwrite data.
The std::replace is also flawed in that it can only replace single characters with another given character (if I remember this correctly). Who needs that? When I replace, I replace strings.
And std::string doesn't even have a char constructor, only for char*, so you'd have to convert your char into a string to pass it to the constructor or additionally construct the string and use insert.

This may not be 100% correct, but I'm not an expert at this yet.