关于ofstream的问题,大侠帮忙看一下

lysliberty 2003-09-15 10:57:21
#include <iostream>
#include <fstream>

using namespace std;

int main(){

ofstream t("balance", ios::out);
int a=t.fdbuf()->fd();

}
报错如下:
err:
no matching funciton for call to 'std::basic_filebuf<char,std:::char_traits<char>>::fd;
可是在filebuf类中,明明是有fd()这个函数的,哪位大侠告诉我为什么调用不了?



...全文
52 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
John-yi 2003-09-16
  • 打赏
  • 举报
回复
在VC中,STL库中的'std::basic_filebuf中没有fd的定义,旧版的stream库中有。


#include <iostream>
#include <fstream>
改为
#include <iostream.h>
#include <fstream.h>

lysliberty 2003-09-16
  • 打赏
  • 举报
回复
老大,我的问题解决了。
将#include <iostream>
改为:
#include "iostream"
就ok了。

此外,在linux中,iostream跟iostream.h是相同的,fstream跟fstream.h也是如此

23,110

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧