S
stephen henry
Hi All,
I have a class for which I have successfully overloaded the []
operator. I can now address the class (which is a 2d array) as
follows;
C2DArray array;
array[123][100] = 53;
Unfortunately, this does not work if array is a pointer, namely:
C2DArray *array = new C2DArray;
array[123][100] = 53; // Wrong!
I have to use:
(*array)[123][100] = 53;
instead.
Is there any way to overload the [] operator so that it work in the
case where array is the object and a pointer to the object. Either
that, or some nicer way of going about it...
Thanks,
Stephen
I have a class for which I have successfully overloaded the []
operator. I can now address the class (which is a 2d array) as
follows;
C2DArray array;
array[123][100] = 53;
Unfortunately, this does not work if array is a pointer, namely:
C2DArray *array = new C2DArray;
array[123][100] = 53; // Wrong!
I have to use:
(*array)[123][100] = 53;
instead.
Is there any way to overload the [] operator so that it work in the
case where array is the object and a pointer to the object. Either
that, or some nicer way of going about it...
Thanks,
Stephen