注册 登录
编程论坛 C++教室

一个C++程序运行时出错,请教原因

hsnr 发布于 2011-06-01 10:36, 379 次点击
我写了一个C++程序,这个程序的main函数为
int main()
{
    string ipf,opf;
    cout<<endl;
    cout<<"请输入输入数据文件名"<<endl;
    cin>>ipf;
    cout<<endl;
    cout<<"请输入输出数据文件名"<<endl;
    cin>>opf;
    cout<<endl;

    DataBankbyInput data(ipf,opf);

    data.InputBasic(NELEM,NPOIN,NDIME,NNODE,NXDIM,NYDIM,
        IFIRST,ISECOND,DTIME,TTIME,NTIME);
....
}
类的定义为
class DataBankbyInput
{
private:
    string ipfName,opfName;
public:

    DataBankbyInput(string ipf,string opf):ipfName(ipf),opfName(opf){};
    void InputBasic(int& NELEM,int& NPOIN,int& NDIME,int& NNODE,int& NXDIM,int& NYDIM,
        int& IFIRST,int& ISECOND,double& DTIME,double& TTIME,int& NTIME);
      ~DataBankbyInput(){};
};

void DataBankbyInput::InputBasic(int& NELEM,int& NPOIN,int& NDIME,int& NNODE,int& NXDIM,int& NYDIM,
    int& IFIRST,int& ISECOND,double& DTIME,double& TTIME,int& NTIME)
{
    ifstream inputfile;
    inputfile.open(ipfName.c_str());
    if(inputfile.fail())
    {
        cout<<"第一个基本数据(输入)文件无法打开"<<endl;
        cout<<endl;
        exit(1);
    }

    ofstream outputfile;
    outputfile.open(opfName.c_str());
    if(outputfile.fail())
    {
        cout<<"第一个基本数据(输出)文件无法打开"<<endl;
        cout<<endl;
        exit(2);
    }
运行时,出现错误提示“第一个基本数据(输入)文件无法打开”,请问问题出在哪?
0 回复
1