Is passing a string by "" equivalent to passing a string by calling std::str("") in C++?
e.g. given a function which accepts std::str as an argument:
void funcA(std::string arg) {
arg = "abc";
}
Should I call it by funcA(std::string("abc")); or funcA("abc"); ? i.e. is the second version a typecast from an array of char?
stringandchar []are two very distinct data types, and although they represent the same concept (character strings), when discussing a question like this, the difference is not negligible.std::stringmaintains a variable number of characters in a contiguous block of memory. Quite different, but same in terms of pointer arithmetic.