Possible Duplicate:
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();
Why would I want to create a pointer object of type Test2? Why not just do non pointer version of Test2? Why would I want to do pointer objects?
Found answer here:
The reasons to use dynamic storage include (but probably not limited to)
When it makes no difference, it is always better to create the object using your
t3method. Don’t use dynamic memory unless you have to. But sometimes you really have to (see the reasons above).