谢谢二楼和四楼的解答,为了使您能更清晰地了解程序的问题,我把所有的对象传上来。如下:
double** Mmatrix::WMmatrix(int ielem)
{
int Ngauss;
double Posgp[10];
double Weigp[10];
int iNxd,jNyd,iG,jG;
double dSum;
double** pMtr;
double JaDet,Weight;
TwoArrayAllocation pT;
pMtr=pT.TwoArrayDoubleAlloc((Nx+1)*(Ny+1),(Nx+1)*(Ny+1));
XYandPhaiDifferential JD;
GaussianQuadrature(Ngauss,Posgp,Weigp);
for(iNxd=0;iNxd<(Nx+1)*(Ny+1);iNxd++)
{
for(jNyd=0;jNyd<(Nx+1)*(Ny+1);jNyd++)
{
dSum=0;
for(iG=0;iG<Ngauss;iG++)
{
for(jG=0;jG<Ngauss;jG++)
{
JaDet=JD.JacobiDeterminant(ielem,Posgp[iG],Posgp[jG]);
Weight=Weigp[iG]*Weigp[jG];
pMtr=SumforDegree(Posgp[iG],Posgp[jG]);
dSum+=pMtr[iNxd][jNyd]*Weight*JaDet;
cout<<"Weight="<<Weight<<endl;
cout<<"JacobiDeterminant="<<JaDet<<endl;
cout<<"pMtr_0["<<iNxd<<"]["<<jNyd<<"]="<<pMtr[iNxd][jNyd]<<endl;
}
}
pMtr[iNxd][jNyd]=dSum;
cout<<"pMtr["<<iNxd<<"]["<<jNyd<<"]="<<pMtr[iNxd][jNyd]<<endl;
}
}
return(pMtr);
pT.DoubleTwoArrayFree((Nx+1)*(Ny+1),pMtr);
}
double** TwoArrayAllocation::TwoArrayDoubleAlloc(int nRow,int nCol)
{
pToDoubleMatrix=new double* [nRow];
if(!pToDoubleMatrix)
{
cout<<"内存分配失败!"<<endl;
exit(-1);
}
for(int j=0;j<nRow;j++)
{
pToDoubleMatrix[j]=new double [nCol];
if(!pToDoubleMatrix)
{
cout<<"内存分配失败!"<<endl;
exit(-1);
}
}
return pToDoubleMatrix;
}
double** Mmatrix::SumforDegree(double ksi,double nda)
{
int i,j,k,l,inode,jnode;
double** pLM;
double aPhai;
double bPhai;
TwoArrayAllocation pTwoArray;
pLM=pTwoArray.TwoArrayDoubleAlloc((Nx+1)*(Ny+1),(Nx+1)*(Ny+1));
XYandPhaiDifferential Phai;
inode=0;
for(i=0;i<=Nx;i++)
{
for(j=0;j<=Ny;j++)
{
aPhai=Phai.InterpolationCoord(i,j,ksi,nda);
inode++;
jnode=0;
for(k=0;k<=Nx;k++)
{
for(l=0;l<=Ny;l++)
{
bPhai=Phai.InterpolationCoord(k,l,ksi,nda);
jnode++;
pLM[inode-1][jnode-1]=aPhai*bPhai;
//
cout<<"pLM["<<inode-1<<"]["<<jnode-1<<"]="<<pLM[inode-1][jnode-1]<<endl;
}
}
}
}
return(pLM);
pTwoArray.DoubleTwoArrayFree((Nx+1)*(Ny+1),pLM);
}
void Mmatrix::GaussianQuadrature(int& Ngauss,double Posgp[10],double Weigp[10])
{
Ngauss=2;
Posgp[0]=-0.577350269189626;
Weigp[0]=1;
Posgp[1]=0.577350269189626;
Weigp[1]=1;
return;
}
所有相关的模块就这些,如果我对二级指针理解错了,肯定上面这些模块也有同样的错误,那问题可大了!请指教。