1 malloc与free是C++/C语言的标准库函数,new/delete是C++的运算符。
2,malloc, 必须 包含头文件<stdlib.h>
3,
nt* p_scalar =new int(5);//Does not create 5 elements, but initializes to 5
int* p_array =new int[5];//Creates 5 elements
delete[] p_array;
2023-02-25 10:57:06
1 malloc与free是C++/C语言的标准库函数,new/delete是C++的运算符。
2,malloc, 必须 包含头文件<stdlib.h>
3,
nt* p_scalar =new int(5);//Does not create 5 elements, but initializes to 5
int* p_array =new int[5];//Creates 5 elements
delete[] p_array;