C ++: is it recommended to create your own String class?

I am reading a C ++ tutorial, and the author says that most C ++ compilers contain a String class library, but even so, it is recommended that you create your own String class. Unfortunately, the author does not indicate why. Does anyone disagree and agree and why?

I use Xcode, and the String class that is provided to me seems fine to me, but again, I only worked with it for a few hours, so I would not know the limitations.

Thanks in advance.

+3
source share
5 answers

It seems to me that you have an old book.

++ std::string, , , .

, , , . - "" .

+6

++ String. std::string, . , #include <string>.

, std::string, , . (MS CString, RogueWave RWCstring), , .

+3

String

, String, .

( ) String

+2

std::string , , , , .. , std::string class ( ), std::string .

+1

There are several reasons why you might need to create your own class of strings, for example, you can create an immutable string class with functions optimized for creating new derived strings, rather than modifying existing strings, as they can sometimes play better with multi-threaded code. However, this is certainly not what you will need to do if you are reading a beginner's book and probably should be reviewed at least three times.

As people said, std :: string is what you need to use for 99.9% of things.

0
source

All Articles