Why can't I add pointers

Posted by Knowing me knowing you on Stack Overflow See other posts from Stack Overflow or by Knowing me knowing you
Published on 2010-05-29T12:36:12Z Indexed on 2010/05/29 12:42 UTC
Read the original article Hit count: 318

Filed under:
|

Having very similiar code like so:

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

Why I'm getting an err in one place and not in both?

© Stack Overflow or respective owner

Related posts about c++

Related posts about pointers