返回信息流1 #include<fstream>
2 #include<string>
3 ifstream& open_file(ifstream &in, const string &file)
4 {
5 in.close();
6 in.clear();
7 in.open(file.c_str());
8 return in;
9 }
编译时出现一下错误:
open_file.cc:3: error: expected constructor, destructor, or type conversion be
re �&� token
不知在哪里出了问题,请大牛给指点一下
这是一条镜像帖。来源:北邮人论坛 / cpp / #29533同步于 2009/10/9
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
【求助】代码很短,但不知问题出在哪里
duguyexing
2009/10/9镜像同步9 回复
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
如果是一个头文件,就是上面函数的原型声明,只有一句话
ifstream& open_file(ifstream&, const string&);
还需要加using namespace std 吗?
编译时也出现这个问题:
open_file.cc:3: error: expected constructor, destructor, or type conversion be
re �&� token
【 在 duguyexing 的大作中提到: 】
: 如果是一个头文件,就是上面函数的原型声明,只有一句话
: ifstream& open_file(ifstream&, const string&);
: 还需要加using namespace std 吗?
: ...................
要的
ifstream是std命名空间的,所以要有。
【 在 duguyexing 的大作中提到: 】
: 如果是一个头文件,就是上面函数的原型声明,只有一句话
: ifstream& open_file(ifstream&, const string&);
: 还需要加using namespace std 吗?
: ...................