为什么样两个指针相加没有意义?如何挑选一块合格好使的指针式万用表
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
- 5星
- 4星
- 3星
- 2星
- 1星
- 暂无评论信息