答案:是。
验证程序
[root@gdc1000 z]# g++ -o test test.cpp
[root@gdc1000 z]# ./test
One
One
One
[root@gdc1000 z]# vi test.cpp
[root@gdc1000 z]# cat test.cpp
#include <string>
#include <memory.h>
#include <malloc.h>
#include <iostream>
int main()
{
char *p = (char *)malloc(8);
memcpy(p, "One",4);
std::string str = p;
std::cout << str << std::endl;
memcpy(p, "Two",4);
std::cout << str << std::endl;
free(p);
p = 0;
std::cout << str << std::endl;
return 1;
}
[root@gdc1000 z]#