TH> I want to overload the '[' to facillitate 2-dimentional arrays, ie.
It's actually the [] operator, but...
TH> thisVal = table[x][y];
TH> Since 'table' is dynamically allocated, stactic subscripting does not
TH> work here. Overloading a single subscript is easy, but two...???
You basically need to have a class that holds arrays of pointers.
class Table
{
// ...
table_type* operator[](size_t index);
};
So long as this class will hold your array of pointers, it can simply be
returned here. It can then also handle your memory allocation/deallocation
for you.
table[x] will be a pointer to table_type. Which will be a single-subscript
array. So if you seperate this:
table_type* t = table[x];
thisVal = t[y];
You can see this works. So, get rid of the temp var 't'.
Good luck!
---
---------------
* Origin: Tanktalus' Tower BBS (1:250/102)
|