class Object {
int val;
};
int main() {
Object Obj;
Obj = Object();
return 0;
}
在main函数的第2行之后,即在“obj = Object()”之后,假设在编译过程中没有使用优化的情况下,main函数的堆栈帧中将存在多少个对象?堆栈上有多少个对象?
class Object {
int val;
};
int main() {
Object Obj;
Obj = Object();
return 0;
}
在main函数的第2行之后,即在“obj = Object()”之后,假设在编译过程中没有使用优化的情况下,main函数的堆栈帧中将存在多少个对象?堆栈上有多少个对象?
由于只有一个变量,堆栈上只有一个对象。
对于所有的时间? – 2015-03-30 20:30:59
是的。变量意味着堆栈上的空间。 C++ oposite to managed languages不会在作用域结束之前释放堆栈空间 – Aik 2015-03-30 20:35:07
创建的临时对象怎么样? – 2015-03-30 20:57:52
[无](http://goo.gl/I5vn8z) – chris 2015-03-30 19:19:40
你为什么这么说? – UnSat 2015-03-30 19:21:50
@ user114754你看过装配了吗? – Borgleader 2015-03-30 19:22:33