为什么只能减去指针? [英] Why pointers can only be subtracted ?

查看:79
本文介绍了为什么只能减去指针?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们不能添加两个指针,我们不能增加两个指针,我们不能用b
除以两个指针,但我们可以减去两个指针。为什么?

We cann''t add two pointers, We cann''t multiply two pointers, We cann''t
divide two pointers, But We can subtract two pointers. Why ?

推荐答案

Abhishek Jha写道:
Abhishek Jha wrote:
我们不能添加两个指针,我们不能成倍增加两个指针,我们不能分割两个指针,但我们可以减去两个指针。为什么?
We cann''t add two pointers, We cann''t multiply two pointers, We cann''t
divide two pointers, But We can subtract two pointers. Why ?




快!拿一本好书!

问:指针变量包含什么?

A:________________(填空)


问候,

Jonathan。


-

电子邮件:" jonathan [period] burd [commercial-at] gmail [期间] com sans-WSP


我们必须做点什么。这是事情。因此,我们必须这样做。

- Keith Thompson



Quick! Grab a good book!
Q: What does a pointer variable contain?
A: ________________ (fill in the blanks)

Regards,
Jonathan.

--
Email: "jonathan [period] burd [commercial-at] gmail [period] com" sans-WSP

"We must do something. This is something. Therefore, we must do this."
- Keith Thompson


Abhishek Jha写道:
Abhishek Jha wrote:

我们不能添加两个指针,我们不能增加两个指针,我们不能分割两个指针,但我们可以减去两个指针。为什么?

We cann''t add two pointers, We cann''t multiply two pointers, We cann''t
divide two pointers, But We can subtract two pointers. Why ?




指针为我们提供了一个位置。如果你喜欢

,可以把它想象成一个街道号码(至少,这个解释的目的)。


考虑地址1562 Ram Street and 1838 Ram Street。


如果我们添加这些,我们得到3400 Ram Street,但这意味着什么?

没什么,真的。甚至可能没有这样的地址。


如果我们乘以它们,我们得到2870956平方街道平方。

无意义。


如果我们将一个除以另一个,我们得到0.再次,毫无意义。


但是如果我们从另一个中减去一个,我们得到276 - 数字<你必须走过去从一个到另一个的房子


(包括其中一个终点)。结果是一个

有用的数字。


注意我们可以有用地添加带整数的指针。

For例如,1562 Ram Street + 276给了我们1838 Ram Street,一个

的有用地址。



A pointer gives us a location. Think of it as a street number if
you like (for the purposes, at least, of this explanation).

Consider the addresses 1562 Ram Street and 1838 Ram Street.

If we add these, we get 3400 Ram Street, but what does that mean?
Nothing, really. There may not even be such an address.

If we multiply them, we get 2870956 Ram squared Street squared.
Meaningless.

If we divide one by the other, we get 0. Again, meaningless.

But if we subtract one from the other, we get 276 - the number
of houses you''d have to walk past to get from one to the other
(including one of the end points). This turns out to be a
useful number.

Note that we can usefully do addition of pointers with integers.
For example, 1562 Ram Street + 276 gives us 1838 Ram Street, a
useful address.


infobahn< in ****** @ btinternet.com>写道:
infobahn <in******@btinternet.com> writes:
考虑地址1562 Ram Street和1838 Ram Street。


[...]

但如果我们从另一个中扣除一个,我们得到276 - 你想要的房子数量必须走过去从一个到另一个
(包括其中一个终点)。结果证明这是一个有用的数字。
Consider the addresses 1562 Ram Street and 1838 Ram Street.
[...]
But if we subtract one from the other, we get 276 - the number
of houses you''d have to walk past to get from one to the other
(including one of the end points). This turns out to be a
useful number.




你必须住在一个地址不同的地方。

在这附近,你所获得的价值将不会是这样的。

细粒度的意义。所有你能说的是1838 Ram Street

大概距离1562 Ram Street大约4个街区(包括

结束区块)。

- -

事实上,有一场圣战并不意味着其中一方

并不吸吮 - 通常两者都做...... ;

- 亚历山大·维罗



You must live in a place with a different approach to addresses.
Around here, the value you''d get would not be of such
fine-grained meaning. All you could say is that 1838 Ram Street
is probably about 4 blocks from 1562 Ram Street (including the
end blocks).
--
"The fact that there is a holy war doesn''t mean that one of the sides
doesn''t suck - usually both do..."
--Alexander Viro


这篇关于为什么只能减去指针?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆