【发布时间】:2011-02-12 11:58:38
【问题描述】:
可能重复:
Why would you ever want to allocate memory on the heap rather than the stack?
Test2 *t2 = new Test2();
t2->test();
Test2 t3;
t3.test();
为什么要创建 Test2 类型的指针对象?为什么不只做Test2的非指针版本?我为什么要做指针对象?
在这里找到答案:
【问题讨论】:
-
很多重复,第一个是(来自 Firas Assaad 的回答)stackoverflow.com/questions/1549945/…
-
我现在意识到了。然而,问这个问题是困难的部分。现在我想我明白了……:D