c++ - 为什么C++语言的malloc函数前面要写指针类型?

int *pi = malloc(sizeof(int));

用C语言可以,但用C++语言会编译出错。

在C++语言中,应该这样使用。

int *pi = (int*) malloc(sizeof(int));

C和C++语言中的malloc函数有什么区别?

相关文章:

ios - React native Pod 安装得到权限被拒绝

javascript - 使用 filter() 而不是 map() 来修改对象数组?

reactjs - 配置多个下一个插件 : withMDX, withBundleAnalyzer

python - 导入错误 : No module named 'typing' when tryi

email - SendGrid Automated Security 如何处理 SPF 记录?

perl - 什么意思 "Can' t locate object method.."在这个使用 P

python - 在合并和排序函数中列出超出范围的索引

asp.net-core - 如何在 ASP.NET Core 3.1 中为 Swagger 指定默

dart - 在 Dart 中,给定可空类型 `T?` ,我如何获得不可空类型 `T`

javascript - 尝试调试 javascript : "vscode listen eacc