Uday wrote:
i have defined a template two dimensional array. its working
fine. since the operator[] function gives me only the row index, i
couldn't catch the column index overflow. is there any way to find &
check it wothout using operator()(int row, int column) function?
Interesting problem. One solution I could think of is have the
operator[] of the 2D array return not a pointer to the selected row (and
use the standard C operator[] for pointers to the column dereferencing),
but have it return a special temporary object that represents the
column, and has another overloaded operator[] to do range checking and
dereferencing. C++ compilers should be able to optimize away most -- if
not all -- the overhead inherent in creating/returning a temporary.
Hope this helps,
Oliver
--
Email:
kr*****@cs.ucdavis.edu
WWW:
http://graphics.cs.ucdavis.edu/~okreylos/ResDev