首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

求纠正一下解决方法

2012-04-02 
求纠正一下C/C++ code#include iostream#include fstream#include string/*********readKeyword(str

求纠正一下

C/C++ code
#include <iostream>#include <fstream>#include <string>/*********readKeyword(string strLabel, string &strReturn)这个&strReturn不太明白啥用..********/using namespace std;class lOKeyword{private:    string strLabel;    //标签    string *strReturn;    //内容    string strFile;        //路径    ifstream readFile;    //文件    string temp;        //临时public:    lOKeyword();        //初始化    ~lOKeyword();        //释放    int readKeyword(string strLabel, string &strReturn);    //接口};lOKeyword::lOKeyword(){    cout << "请输入路径: ";    cin >> strFile;    readFile.open(strFile.c_str());}lOKeyword::~lOKeyword(){    readFile.close();}int lOKeyword::readKeyword(string strLabel, string &strReturn){    while(readFile >> temp)    {        if(temp == "<"+strLabel+">")        {            temp = " ";        }        if(temp == "</"+strLabel+">")        {            temp = " ";        }        cout << temp << endl;        strReturn = temp;        this->strReturn = &strReturn;    }    this->strLabel = strLabel;    return 0;}int main(){    lOKeyword p;    string one, *two;    cout << "请输入标签: ";    cin >> one;    p.readKeyword(one, *two);    return 0;}


[解决办法]
string &strReturn这个就是个引用。。。就是别名

热点排行