How safely override function

Hi all

I wanted to ask if anyone knows how I can safely override function. Here is what i am trying to do:

 
virtual T& operator[] (unsigned r_, unsigned c_) {return Values[r_+c_*numRows];};


I am getting this error:
 
Error	1	error : too many parameters for this operator function

I understand that since Values is just a vector it doesn't like to accept two arguments.
Does anyone knows how to overcome this?
I am using Intel C++ with Visual Studio 2010

Any help would be appreciated.
This function shall be a member of a class and have only one parameter.
Is there anyway to trick it to use two arguments.

I want to use it as Matrix something like.
1
2
3
4
5
6
7
8
9
Matrix<double> M(10, 10);

for(int i = 0; i < 10; i++)
{
     for(int j = 0; j < 10; j++)
     {
          M[i,j] = i+j;
      }
}


But due to some limitation of Intel MKL I have to have my matrix in one singe vector all together to use some functions, so I am trying to accommodate normal use of matrix and ability to call some functions from Intel MKL

Thanks for reply.
It is enough to have subscript operator for one index. Only you should return a reference to one dimensional array provided that inside your class there is a two-dimensional array as a data member.
Last edited on
Topic archived. No new replies allowed.