Why can't I add pointers?

前端 未结 7 898
终归单人心
终归单人心 2020-11-30 00:38

I have code very similiar to this:

LINT_rep::Iterator::difference_type LINT_rep::Iterator::operator+(const Iterator& right)const
{
    return (this + &am         


        
7条回答
  •  长情又很酷
    2020-11-30 01:41

    Lets say you have 2 pointers and you know one or both of them are null. You want to return the one that is not null or null in case both are null. The easiest way would be to sum/xor them. This is the propper case to sum pointers.

提交回复
热议问题