【发布时间】:2017-07-13 01:37:13
【问题描述】:
我的代码与此非常相似:
LINT_rep::Iterator::difference_type LINT_rep::Iterator::operator+(const Iterator& right)const
{
return (this + &right);//IN THIS PLACE I'M GETTING AN ERROR
}
LINT_rep::Iterator::difference_type LINT_rep::Iterator::operator-(const Iterator& right)const
{//substracts one iterator from another
return (this - &right);//HERE EVERYTHING IS FINE
}
err msg: Error 1 error C2110: '+' : cannot add two pointers
为什么我只在一个地方出现错误,而不是在两个地方?
【问题讨论】:
-
添加指针意味着什么?如果您的家庭住址是 3472 Main,添加 2 之类的数字将为您提供 3474 Main,可能是邻居。但是将这两个地址相加会得到 6946。这是什么意思?