我有以下代码:
string * p = new string[8];
cout<<sizeof(p)<<endl;
free(p);
这对我来说似乎还可以,但失败了:
8
a.out(85837) malloc: *** error for object 0x7fb5b3403ae8: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
对整数数组的另一项测试有效。c++ 字符串有什么特别之处吗?