在 C + + 中,
Aside from dynamic memory allocation, is there a functional difference between the following two lines of code:
Time t (12, 0, 0); //t is a Time object
Time* t = new Time(12, 0, 0);//t is a pointer to a dynamically allocated Time object
当然,我假设已经定义了一个 Time (int,int,int) ctor。我还意识到,在第二种情况下,需要删除 t,因为它是在堆上分配的。还有别的区别吗?