But here, as we saw in week zero with the shoe example putting on socks, I have to increment this variable explicitly myself.
但是这里,像我们上周看到的,鞋子穿在袜子上,我需要亲自明确地增加这个变量。
It does, in fact, successfully increment X, because at this point in the story, X was not scoped to main.
它实际上成功的增加了X的值,因为在这个地方,X不是main中的范围。
The exact shape of the curve is subject to discussion, but the point of diminishing marginal utility is that, as you get more and more money, the increment in utility for each extra dollar diminishes.
这条曲线的确切形状还有待讨论,但是边际效用递减规律的重点在于,你得到的钱越多,每额外的一美元的增长效用会相对减小
Now if you call a function, swap like increment or cube or swap, or in this case, foo, those variables are the parameters to that function, end up getting stored next in memory.
现在如果你调用一个函数,像increment或者cube或者,或者在这个例子里,foo,这些变量都是,函数的参数,在内存中存储。
So even though increment is obviously increment declared and defined in this function, it's later; so it's too late for me to use it in main.
很明显,即使在这个函数中,已经声明和定义;,也太迟了,以至于,我在main函数中不能使用它。
And then on the right hand side I++, we saw that in pseudocode with our socks example last week that just says increment I.
然后是最右边的i++,我们上周在socks例子的伪代码中,曾经见到过,不是么?只是代表i加1而已。
So pictorially, it's as though there's now some other part of the blackboard here, maybe way up here where I can put anything I want that's accessible to main, that's accessible to swap, that's accessible to increment or any other function I might implement because it is, in fact, global.
绘画般地,它是在这里黑板上的其他部分,可能在这里的上面,我在哪里可以放置这些东西,使它们可以被main函数使用,可以被swap函数使用,可以被increment函数使用,或者我所实现的其它函数,因为它实际上是一个全局变量。
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的时候,实际上在内存中,有两个同样的值的内存块,但是它们有不同的名字。
应用推荐