| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1244 人关注过本帖
标题:string对象不能作为函数参数进行传递吗?
只看楼主 加入收藏
hsnr
Rank: 1
等 级:新手上路
帖 子:83
专家分:0
注 册:2010-4-4
结帖率:90.32%
收藏
 问题点数:0 回复次数:0 
string对象不能作为函数参数进行传递吗?
// Input all basic data of this c++ program

void InputBasic(string IfStr,string OfStr)
{
    ifstream inputfile;
    cout<<endl;
    cout<<"请输入第一个基本数据(输入)文件名"<<endl;
    cin>>IfStr;
    cout<<endl;
    inputfile.open(IfStr.c_str());
    if(inputfile.fail())
    {
        cout<<"第一个基本数据(输入)文件无法打开"<<endl;
        cout<<endl;
        exit(1);
    }

//
    ofstream outputfile;
    cout<<"请输入第一个基本数据(输出)文件名"<<endl;
    cin>>OfStr;
    cout<<endl;
    outputfile.open(OfStr.c_str());
    if(outputfile.fail())
    {
        cout<<"第一个基本数据(输出)文件无法打开"<<endl;
        cout<<endl;
        exit(2);
    }
   ...............

    inputfile.close();
    outputfile.close();
    return;
}

void InputBasicData(string IfStr,string OfStr)
{
    ifstream inputfile;
    inputfile.open(IfStr.c_str(),ios_base::in|ios_base::app);
    inputfile.seekg(8*sizeof(int)+2*sizeof(double), ios::beg);
    if(inputfile.fail())
    {
        cout<<"基本数据(输入)文件无法打开"<<endl;
        exit(2);
    }
//
    ofstream outputfile;
    outputfile.open(OfStr.c_str(),ios_base::out|ios::app);
    if(outputfile.fail())
    {
        cout<<"基本数据(输出)文件无法打开"<<endl;
        exit(2);
    }
    ..............

    inputfile.close();
    outputfile.close();

    return;
}
int _tmain(int argc, _TCHAR* argv[])
{
    string IfStr,OfStr;
    data.InputBasic(IfStr,OfStr);
    cout<<IfStr<<OfStr<<endl;// 不能输出!
    data.InputBasicData(IfStr,OfStr);
   ................
    return 0;
}
搜索更多相关主题的帖子: string 函数 参数 对象 
2010-05-14 14:46
快速回复:string对象不能作为函数参数进行传递吗?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014636 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved