我是C++新手。C++中的一個類的多維矩陣
class ProjectionValue{
public:
int angleLength;
int detectorIndex_xLength;
int detectorIndex_yLength;
double ***matrix;
ProjectionValue(int angleLength, int detectorIndex_xLength, int detectorIndex_yLength);
~ProjectionValue();
};
我在我的主類中聲明瞭ProjectionValue類(我的類)的3d矩陣。
ProjectionValue*** A_projection [10][10][5];
for(int x=0; x< A->Tomo->object3d->Nx; x++)
{
for(int y=0; y< A->Tomo->object3d->Ny; y++)
{
for(int z=0; z< A->Tomo->object3d->Nz; z++)
{
for(int kk=0; kk<11; kk++)
{
for(int m=0; m < A->Tomo->detector->Nx; m++)
{
for(int n=0; n < A->Tomo->detector->Ny; n++)
{
(**A_projection[x][y][z])->matrix[kk][m][n] = A->Tomo->ICD_projection(*A->Tomo->xraysource->Source,*A->Tomo->detector->GetCoordinates(m,n), initial_object, x, y, z);
}
}
A->Tomo->xraysource->RotateXRaySource(-5);
A->Tomo->detector->RotateDetector(-5);
}
}
}
}
我把「在Form_Solution.exe中出現'System.AccessViolationException'類型的未處理的異常」。它在這裏:
(**A_projection[x][y][z])->matrix[kk][m][n] = A->Tomo->ICD_projection(*A->Tomo->xraysource->Source,*A->Tomo->detector->GetCoordinates(m,n), initial_object, x, y, z);
我能爲這個問題做些什麼,在我的3d矩陣類的聲明中有什麼問題嗎?矩陣的分配內存是必需的,我該怎麼做?
你還沒有爲你的矩陣分配內存 – SomeWittyUsername 2013-03-19 16:43:46
我該如何分配這個矩陣? – 2013-03-19 16:47:26
[三星程序員]的必須鏈接(http://c2.com/cgi/wiki?ThreeStarProgrammer)。 – 2013-03-19 17:34:54