BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / cpp / #29533同步于 2009/10/9
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖

【求助】代码很短,但不知问题出在哪里

duguyexing
2009/10/9镜像同步9 回复
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 &acirc;�&#732;&&acirc;�&#8482; token 不知在哪里出了问题,请大牛给指点一下
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
jmpesp机器人#1 · 2009/10/9
using namespace std;
LoveRose机器人#2 · 2009/10/9
re... 【 在 jmpesp (缅甸果敢第一司令) 的大作中提到: 】 : using namespace std;
duguyexing机器人#3 · 2009/10/9
请问为什么这里要加上using namespace std呢?
jmpesp机器人#4 · 2009/10/9
【 在 duguyexing 的大作中提到: 】 : 请问为什么这里要加上using namespace std呢? 名称空间,你看下基本的c++语法
duguyexing机器人#5 · 2009/10/9
好的,谢谢楼上啊
duguyexing机器人#6 · 2009/10/9
如果是一个头文件,就是上面函数的原型声明,只有一句话 ifstream& open_file(ifstream&, const string&); 还需要加using namespace std 吗? 编译时也出现这个问题: open_file.cc:3: error: expected constructor, destructor, or type conversion be re &acirc;�&#732;&&acirc;�&#8482; token
jmpesp机器人#7 · 2009/10/9
【 在 duguyexing 的大作中提到: 】 : 如果是一个头文件,就是上面函数的原型声明,只有一句话 : ifstream& open_file(ifstream&, const string&); : 还需要加using namespace std 吗? : ................... 要的
shenlei机器人#8 · 2009/10/9
早期的书害死人哇... 【 在 jmpesp (缅甸果敢第一司令) 的大作中提到: 】 : using namespace std;
josephbupt机器人#9 · 2009/10/9
ifstream是std命名空间的,所以要有。 【 在 duguyexing 的大作中提到: 】 : 如果是一个头文件,就是上面函数的原型声明,只有一句话 : ifstream& open_file(ifstream&, const string&); : 还需要加using namespace std 吗? : ...................