大家讲道理2017-04-17 13:13:15
Test * test_ptr = new Test(); allocated on the heap
Test test; on the stack
迷茫2017-04-17 13:13:15
Test *ptr = new Test;
Test::array is on the heap, ptr itself is on the stack...
PHP中文网2017-04-17 13:13:15
It’s been 15 years and it’s time to use c++11
Smart pointers are safer
//分配在堆上,多了不会爆栈,当然也不能大的太离谱了
auto test_ptr = shared_ptr<Test>(new Test());
//在栈上,多了会爆栈的
Test test;