If I convert a std::string into a CString using something like:
std::string ss("Foo");
CString cs( ss.c_str() );
Does the CString copy the characters from ss or does it simply copy the char* pointer?
My understanding of the c_str() function is that it returns a pointer to a character array owned by the std::string. So having a CString using this internally would seem like a really bad idea as any nonconstant method on either of them would then invalidate the pointer held in the other.
The
CStringconstructor that takes aconst char*will copy the data into its internal structure. It’s the same as doing this:CString test = "This is a test"or even this
CString test("This is a test")