a[6] = 6 * 10 // I want it to set temp[6][2] to 60
The element `temp[6][2]' won't exist if temp was declared as `temp[10][2]'.
Looks to me like you need to overload the `[]' operator. You can do that like this:
Code:
class Object{
int *arr;
int size;
public:
Object():size(0),arr(0){}
Object(const int n):size(n){
arr = new int[n];
}
~Object(){
if(arr){
delete [] arr;
arr = 0;
}
}
int& operator[](const int n){
if(n < size)
return arr[n];
}
};
So now you can see how to overload the operator, try adapting my code to suit your needs.
Note: I havn't tested this code. It was written straight into the forums text box.