在一个MFC工程中中,我添加了一个类CPower,主程序中定义了一个动态二维数组,而类的构造函数需要使用这个二维数组进行初始化,相关程序代码如下: class CPower
{
private: i
nt m_nNodeNum,m_nBranNum;
int **m_pCorrMatrix;
double *m_pdReactVal;
double *m_pdPowerVal;
public:
CPowerSys(int,int,int**pCorrMatrix,double*pdReactVal,double*pdPowerVal);
virtual ~CPowerSys();
void GetSysY(const int m_nNodeNum,const int m_nBranNum,const int**m_pCorrMatrix,const double*m_pdReactVal);
};
/////////////////////////////////////////////////////////////////////////////
void main()
{
int nNodeNum,nBranNum;
int **pCorrMatrix;
double *pdReactVal;
double *pdPowerVal;
cin>>nNodeNum>>nBranNum;
pCorrMatrix=new int*[nNodeNum-1];
for(int i=0;i<nNodeNum-1;i++)
pCorrMatrix[i]=new int[nBranNum];
pdReactVal=new double[nBranNum];
pdPowerVal=new double[nBranNum];
for(i=0;i<nNodeNum-1;i++)
for(int j=0;j<nBranNum;j++)
cin>>pCorrMatrix[i][j];
for(i=0;i<nBranNum;i++) cin>>pdReactVal[i];
for(i=0;i<nBranNum;i++)
cin>>pdPowerVal[i];
/////////////////////////////////////////////////////////////////////////////
// 调用
CPowerSys PowerSysModel(nNodeNum,nBranNum,**pCorrMatrix,*pdReactVal,*pdPowerVal);
PowerSysModel.GetSysY(int m_nNodeNum,int m_nBranNum,int**m_pCorrMatrix,double*m_pdReactVal);
}
编译后出现以下错误:
error C2664: '__thiscall CPowerSys::CPowerSys(int,int,int ** ,double *,double *)' : cannot convert parameter 3 from 'int' to 'int **
error C2144: syntax error : missing ')' before type 'int'
error C2660: 'GetSysY' : function does not take 0 parameters
请高手大侠不吝指教,谢谢!
还有问题……
PowerSysModel.GetSysY(m_nNodeNum,m_nBranNum,m_pCorrMatrix,m_pdReactVal);
我这里调用的是类的成员函数,m_nNodeNum和m_nBranNum等参数都是类的成员变量,为什么编译的时候会出现
error C2065:'m_pCorrMatrix' : undeclared identifier
error C2065: 'm_pdReactVal' : undeclared identifier
这样的错误?
我该怎么办?