subscript operator on pointers

Posted by Lodle on Stack Overflow See other posts from Stack Overflow or by Lodle
Published on 2010-05-11T04:14:01Z Indexed on 2010/05/11 4:24 UTC
Read the original article Hit count: 186

Filed under:
|

If i have a pointer to an object that has an overloaded subscript operator ( [] ) why cant i do this:

 MyClass *a = new MyClass();
 a[1];

but have to do this instead:

 MyClass *a = new MyClass();
 (*a)[1];

© Stack Overflow or respective owner

Related posts about c++

Related posts about operator-overloading