Duplicar posible:
Why would you ever want to allocate memory on the heap rather than the stack?objetos C++ Pointer frente a no Puntero Objetos
Test2 *t2 = new Test2();
t2->test();
Test2 t3;
t3.test();
¿Por qué querría para crear un objeto de tipo puntero Prueba2? ¿Por qué no simplemente hacer la versión no puntero de Test2? ¿Por qué querría hacer objetos de puntero?
respuesta Encontrado aquí:
- Why would you ever want to allocate memory on the heap rather than the stack?
- When is it best to use a stack instead of a heap and vice versa?
- When to use "new" and when not to in C++?
- When should I use the new keyword in C++?
- Proper stack and heap usage in C++
- Stack, Static and Heap in C++
Muchos duplicados, el primero de los cuales es (de respuesta de Firas Assaad) http://stackoverflow.com/questions/1549945/why-would-you-ever-want-to-allocate-memory-on-the-heap -rather-than-the-stack –
Me doy cuenta de eso ahora. Sin embargo, hacer la pregunta fue la parte difícil. Ahora creo que lo entiendo ...: D –