Asked by Dave

Operator overloading: Array indexing [] – allow for double indexing [][]

I'm not sure how to overload the operator[] for double indexing. Please help if you can. Thanks

Answers

Answered by MathMate
You have not mentioned the language with which you are working. Since Java does not allow operator overloading, I assume you are working with C++. It would be nice to mention "Programming C++" or something similar in your subject.

Back to arrays. Native C++ already allows double array indexing. Something like the following already works as is, without additional code.

int a[4][4];
for(int i=0;i<4;i++)for(int j=0;j<4;j++)...

If you want to know more about operator overloading in general, you can read up textbooks, or tutorials such as:
http://www.deitel.com/articles/cplusplus_tutorials/20060204/
There are no AI answers yet. The ability to request AI answers is coming soon!

Related Questions