You can use pointer and store into a matrix, as shown below:
struct stTemp
{
int a;
int b;
};
void test()
{
stTemp* pst;
matrix<uint> mu(3,4);
int ii, jj;
for(ii = 0; ii < mu.GetNumCols(); ii++)
{
for(jj = 0; jj < mu.GetNumRows(); jj++)
{
pst = new stTemp;
pst->a = (jj+1)*10;
pst->b = ii+1;
mu[jj][ii] = (uint)pst;
}
}
for(ii = 0; ii < mu.GetNumCols(); ii++)
{
for(jj = 0; jj < mu.GetNumRows(); jj++)
{
pst = (stTemp*)mu[jj][ii];
printf("mu[%d][%d], a=%d, b=%d\n", jj, ii, pst->a, pst->b);
}
}
//cleanup
for(ii = 0; ii < mu.GetNumCols(); ii++)
{
for(jj = 0; jj < mu.GetNumRows(); jj++)
{
pst = (stTemp*)mu[jj][ii];
delete pst;
mu[jj][ii] = 0;
}
}
}
Best will be to put the new and delete code inside a class so that you can manage the 2D pointers with constructor/destructors.