Would it matter if my C++ code (as shown below) has a string initialized as an empty string:
std::string myStr = ""; ....some code to optionally populate 'myStr'... if (myStr != "") { // do something } vs. no/null initialization:
std::string myStr; ....some code to optionally populate 'myStr'... if (myStr != NULL) { // do something } Are there any concerns here?
NULL(conceptually) is a pointer, and should only be used as such. Astd::stringisn't a pointer, so it shouldn't be combined. PS. the initializations are the same: the ctor ofstd::stringsets it to the empty string.