operator overloading

Hi hi,

is it possible to use operator overloading to overload an "[][]" operator instead of just "[]" ?

What I would like is that upon reading

myContainer[i][j]

the program would go to a member function of the class that myContainer belongs to
and pass it the arguments i and j.

No. You would have to use a proxy type or something. Just overload operator() instead.
Is it "[][]" really a different operator than "[]"? Intuitively I guess it´s just the same thing twice: serching for an index inside something that´s been pulled out of an index as well...

http://www.learncpp.com/cpp-tutorial/98-overloading-the-subscript-operator/
Topic archived. No new replies allowed.