希望这不是一个太基本的问题。我想知道做之间是否有区别
while (1) {
int *a = new int(1);
// Do stuff with a
}
与
int *a;
while (1) {
a = new int(1);
// Do stuff with a
}
在这两种情况下,相同数量的对象都是动态分配的。但是,在第一个示例中,在循环内部使用了 int 关键字这一事实会影响所使用的内存吗?
希望这不是一个太基本的问题。我想知道做之间是否有区别
while (1) {
int *a = new int(1);
// Do stuff with a
}
与
int *a;
while (1) {
a = new int(1);
// Do stuff with a
}
在这两种情况下,相同数量的对象都是动态分配的。但是,在第一个示例中,在循环内部使用了 int 关键字这一事实会影响所使用的内存吗?