我刚写了代码
std::array<std::array<double,3>,27 > dshape;
&dshape[0][0] points to the address ****780
&dshape[0][1] points to the address ****788
&dshape[0][2] points to the address ****790 (I was expecting 796)为什么会这样呢?
发布于 2016-03-06 21:26:37
(我期望的是796)
这只是十六进制符号,不是十进制。
所以
0x780 + 0x008 = 0x788
0x788 + 0x008 = 0x790为什么会这样?
默认情况下,std::ostream& operator<<(std::ostream&, void*)重载打印十六进制值表示形式。
发布于 2016-03-06 21:28:14
我猜您正在使用cout输出地址,因为它是一个地址,所以它将显示在hexadecimal中。
0x790 - 0x788 = 0x08等于:(十进制)
1936 - 1928 = 8https://stackoverflow.com/questions/35827303
复制相似问题