指针数组调用构造函数
时间: 2023-09-29 18:10:21 浏览: 134
数组元素所属类的构造函数-对象数组对象指针
指针数组的调用构造函数的情况与对象数组类似。如果只定义指针而不给指针赋值,则不涉及内存分配,也不会调用构造函数。只有在给指针赋值的时候,才会涉及到内存分配,并且调用构造函数。因此,指针数组的调用构造函数的次数与指针数组的元素个数有关。如果指针数组有N个元素,则调用构造函数的次数为N次。引用<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [关于构造函数调用次数](https://blog.csdn.net/ken2232/article/details/129351130)[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_2"}}] [.reference_item style="max-width: 50%"]
- *3* [观察不同对象分别何时调用构造函数与析构函数_C/C++](https://download.csdn.net/download/weixin_42662171/86695295)[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_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文