operator new()
时间: 2023-10-28 09:04:57 浏览: 90
operator new()是一个用于动态分配内存的函数。它被用来在堆上分配一片指定大小的内存空间,并返回一个指向该内存空间的指针。 通常情况下,当我们使用new运算符来创建一个对象时,实际上会调用operator new()来分配内存,并调用相应的构造函数来创建对象。 operator new()可以被重载,但new操作符本身是不能被重载的。 当类A重载了operator new()函数时,就会使用A::operator new()来分配内存;否则,会使用全局::operator new()来分配内存。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [全面解析C++中的new,operator new与placement new](https://download.csdn.net/download/weixin_38539705/13996607)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [2.STL之::operator new()的理解](https://blog.csdn.net/qq_42698422/article/details/106932482)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [c++ new操作符(new operator)、operator new、placement new 、operator new[] 及相对应的delete 操作符...](https://blog.csdn.net/baidu_16370559/article/details/123354265)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文