H
hall
Hi all.
I'm in the process of writing a 3 dim array class and initially, i
wanted to overload the [] operator so that each element could be
accessed i a way similar to how you access a simple C-style array. Example:
Array[0][1][2];
(where Array is an instance of this class) should returns a reference to
the element with indicies (0,1,2), comparable to how one adresses a
C-style array (here in 2 dim and using int:s):
int *C_array[5];
for (int i=0;i<5;i++) {C_array=new[5]};
array[0][1]; // <- this is what i mean by C-style
The more i think about it, the less do I think it is possible, but
perhaps it is? Is there a simple way of obtaining this syntax or should
I disregard the aestetics and walk the simle way ( Ie using a syntax
like: Array.getRefToElement(0,1,2); to get a reference) ?
regards
hall
I'm in the process of writing a 3 dim array class and initially, i
wanted to overload the [] operator so that each element could be
accessed i a way similar to how you access a simple C-style array. Example:
Array[0][1][2];
(where Array is an instance of this class) should returns a reference to
the element with indicies (0,1,2), comparable to how one adresses a
C-style array (here in 2 dim and using int:s):
int *C_array[5];
for (int i=0;i<5;i++) {C_array=new[5]};
array[0][1]; // <- this is what i mean by C-style
The more i think about it, the less do I think it is possible, but
perhaps it is? Is there a simple way of obtaining this syntax or should
I disregard the aestetics and walk the simle way ( Ie using a syntax
like: Array.getRefToElement(0,1,2); to get a reference) ?
regards
hall