ringa_lee
Test * test_ptr = new Test(); allocated on the heapTest test; on the stack
Test *ptr = new Test;Test::array is on the heap, ptr itself is on the stack...
It depends on where the class is instantiated
It’s been 15 years and it’s time to use c++11Smart pointers are safer
//分配在堆上,多了不会爆栈,当然也不能大的太离谱了 auto test_ptr = shared_ptr<Test>(new Test()); //在栈上,多了会爆栈的 Test test;
Test * test_ptr = new Test(); allocated on the heap
Test test; on the stack
Test *ptr = new Test;
Test::array is on the heap, ptr itself is on the stack...
It depends on where the class is instantiated
It’s been 15 years and it’s time to use c++11
Smart pointers are safer