了解动态变量的实际含义以及它们如何帮助我打造 Vista 是否是个好主意?
听说过
int* g=new int[50];
应该为 50 个整数的数组动态分配内存。 g也被称为动态变量。如果是这样,我的窗口中的动态变量是什么?我认为这更像是一个概念,而不是一些要定义的可计算对象。而我介于两者之间。
最佳答案
你绝对应该读一本好书,但无论如何我都会在这里给你一些简短的答案。
Would it be a good idea for me to learn something what dynamic variables actually mean?
是的。
I have heard that
int* g=new int[50];
is supposed to dynamically allocate memory for an array of 50 integers.
没错。
And g is called a dynamic variable too.
可能有人使用这个术语,但我没有听说过,我不会采用它。
g
本身根本不是动态的。它是一个指针,具有自动存储持续时间(口语中的“在堆栈上”)。它没有特别神奇的特性。
这里的“动态对象”是五十个整数的数组。该对象没有名称,只能通过指针g
(或通过另一个与g
具有相同值的指针)访问。
If so, what are dynamic variables in my windows ? I think this is more of a concept than of some computable objects to define. And I am in the middle of nowhere between both.
我根本不明白这部分问题。
关于c++ - 动态变量和,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7081712/