扫码关注官方订阅号
ringa_lee
Test * test_ptr = new Test(); 分配在堆上Test test; 在栈上
Test *ptr = new Test;Test::array在堆上, ptr本身在栈上...
要看类实例化在哪上
都15年了该用c++11了智能指针更安全
//分配在堆上,多了不会爆栈,当然也不能大的太离谱了 auto test_ptr = shared_ptr<Test>(new Test()); //在栈上,多了会爆栈的 Test test;
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
扫描下载App
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
Test * test_ptr = new Test(); 分配在堆上
Test test; 在栈上
Test *ptr = new Test;
Test::array在堆上, ptr本身在栈上...
要看类实例化在哪上
都15年了该用c++11了
智能指针更安全