I have to put few megabytes of data in two-dimensional arrays in C++ code (embed it in DLL), diffrent datasets for each subclass. I defined virtual accessor methods to access constants to specified subclass but it works only for primitives and 1D arrays, not for 2D arrays:
#include <stdio.h>
class SubClassHoldingData { // inheritance removed for short,compilable example
public:
    static int const notWorkingData[2][2];
    virtual int const** getNotWorkingData() { return (int const**)notWorkingData; } 
};
// simplified data set, about 200x200 in real application
const int SubClassHoldingData::notWorkingData[2][2] =  { { 1 , 2 } , { 3, 4 } };
int main( int argc , char** argv ) {
    SubClassHoldingData* holder = new SubClassHoldingData();
    const int** data = holder->getNotWorkingData();
    printf("data: %d" , data[1][1]); // !!! CRASHES APPLICATION !!!
}
I want to access data dynamiccaly (virtual) but with compile-time constant array like this:
DataHolder* holder = new FirstDataSetHolder();
const int** data = holder->get2DArray();
DataHolder* holder = new SecondDataSetHolder();
const int** data = holder->get2DArray(); 
// "data" contents DIFFERENT now, but compile-time constants!
How to achieve that?
 
     
    