Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

string

class

I'm reading a C++ tutorial book, and the author says most C++ compilers include a String class library, but even if it does, it is recommended to create your own String class. Unfortunately, the author doesn't state why. Does anyone disagree/agree and why?

I'm using Xcode and the String class that is provided seems fine to me, but then again, I've only been working with it for a few hours, so I wouldn't know the limitations.

Thanks in advance.

like image 903
ObjectiveC-InLearning Avatar asked Dec 12 '22 02:12

ObjectiveC-InLearning


1 Answers

Sounds to me like you have an old book.

The C++ standard library includes the std::string class, and you should be using that instead of inventing your own and fixing bugs that have already been encountered and fixed in a widely used library.

As you are a beginner, yes, you should take a swing at implementing your own as it will teach you quite a bit. Just don't use it in any 'real' project.

like image 131
Ed S. Avatar answered Jan 01 '23 07:01

Ed S.