为什么样两个指针相加没有意义?如何挑选一块合格好使的指针式万用表

时间:2018-03-15 20:00:03   浏览:次   点击:次   作者:   来源:   立即下载

Pointer addition is forbidden in C++, you can only subtract two pointers.

The reason for this is that subtracting two pointers gives a logically explainable result - the offset in memory between two pointers. Similarly, you can subtract or add an integral number to/from a pointer, which means \"move the pointer up or down\". Adding a pointer to a pointer is something which is hard to explain. What would the resulting pointner represent?

If by any chance you explicitly need a pointer to a place in memory whose address is the sum of some other two addresses, you can cast the two pointers to int, add ints, and cast back to a pointer. Remember though, that this solution needs huge care about the pointer arithmetic and is something you really should never do.

纯属搬运,哈哈

\", \"extras\": \"\", \"created_time\": ①④⑧⑤④④⑥⑤③⑥ · \"type\": \"answer

收起

相关推荐

相关应用

平均评分 0人
  • 5星
  • 4星
  • 3星
  • 2星
  • 1星
用户评分:
发表评论

评论

  • 暂无评论信息