“One should always use std::string over c-style strings(char *)” is advice that comes up for almost every source code posted here. While the advice is no doubt good, the actual questions being addressed do not permit to elaborate on the why? aspect of the advice in detail. This question is to serve as a placeholder for the same.
A good answer should cover the following aspects(in detail):
- Why should one use
std::stringover c-style strings in C++? - What are the disadvantages (if any) of the practice mentioned in
#1? - What are the scenarios where the opposite of the advice mentioned in
#1is a good practice?
1 Answer