Custom string class (C++)

前端 未结 4 1707
灰色年华
灰色年华 2021-01-05 18:23

I\'m trying to write my own C++ String class for educational and need purposes.
The first thing is that I don\'t know that much about operators and that\'s why I want to

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-05 18:54

    Don't use strlen, store your own string length. The string should not be depended on to have a null terminator. It's ok to use such if you're passed in a random const char*, but for internal operations, you should use the size.

    Also, you forgot to make your operator const char* a const overload.

提交回复
热议问题