Why not write the program in a way where you figure out dynamically when the program is run how much memory you need rather than hard coding in two with or within that constant.
为什么不写一个可以动态的方式写那个程序,程序可以动态分配内存,而不是用常量硬编码两个值。
And those instructions, by the way, are very simple: they're things like, take the value out of two places in memory, and run them through the multiplier in here, a little piece of circuitry, and stick them back into someplace in memory.
顺便说一句,那些指令非常简单:,他们从记忆存储器中,取出两个位置的结果,在倍增器中运行,一小部分电路,再将它们插回存储器中的某些地方去。
You actually need to kind of do this and then you can swap these two numbers but it requires 50 percent more memory.
你实际上需要这样做,然后才能交换两个数字,但是它需要多50%的内存。
Two pieces of memory actually touching each other or you touching memory that you don't actually own, in which case the computer doesn't really know what to do and just, bam.
两块内存相互覆盖,或者你覆盖了不存在的内存,那样的话计算机不知道,该怎么做,只有崩溃。
It's just a little block of memory in RAM, you know, that represents four bytes, 32-bits and the Number Two is currently in it.
它只是一小块内存块,它表示4个字节,32位,那个数字2就存储在里面。
I want an actual copy in memory so that that string is in two different places.
我想要在内存中有一个拷贝,把字符串存储在,两个不同的地方。
B It swaps this one and these two, A and B, but it has no access to main's memory.
它交换了这个和这两个变量,A和,但是它没有介入到main的内存中。
And actually, if I don't want to clobber, as we say, overwrite the value of my variable, ; I could declare another one and store the return value in Y; Y so now I have two ints in memory; X and Y, 3 one with two, one with three.
实际上,如果你不想彻底清除,像我们说的,覆盖那个变量的值,我可以申明另一个变量Y,并在Y中保存那个返回值;,现在内存中有两个int数,X和,一个的值为2,一个为。
And when you call a function, one of the things X that happens is whatever your passing in, for instance, X, ; and if this is A, this thing gets copied into A; so at that moment in time of calling increment, I actually have two copies of the same value in memory but they're referred to by different names.
当你调用一个函数,其中发生的一件事情是,不管你输入什么,比如,或者是A,它把这个东西复制到A中;,调用increment的时候,实际上在内存中,有两个同样的值的内存块,但是它们有不同的名字。
应用推荐