Pointer comparison

后端 未结 2 954
礼貌的吻别
礼貌的吻别 2021-01-19 10:31

Do pointers in C and C++ support comparison operators (>, <, etc.) in standard?

I want to compare array positions to be precise.

2条回答
  •  自闭症患者
    2021-01-19 11:03

    In a contiguous array comparing memory offsets (pointers) is OK. If your array is implemented as a linked list (for example) the nodes could be all over memory so pointer comparison is nonsensical.

提交回复
热议问题