请教filebuf的seekoff问题

ascmvi 2007-08-30 04:09:23
vc7中的filebuf有人用过吗?
basic_filebuf::seekoff
Remarks
The protected virtual member function endeavors to alter the current positions for the controlled streams

我在程序中使用编译就要抱错
error C2248: 'std::basic_filebuf<_Elem,_Traits>::seekoff' : cannot access protected member declared in class 'std::basic_filebuf<_Elem,_Traits>'
那么该怎么解决呢?
...全文
216 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
buyong 2008-12-18
  • 打赏
  • 举报
回复
这是在fstream.h里计算文件长度的做法
taodm 2007-08-30
  • 打赏
  • 举报
回复
那你就自力更生吧。
几乎不会实际使用的功能,研究的人恐怕很少。
也建议你跳过。
glgg 2007-08-30
  • 打赏
  • 举报
回复
taodm((不能收CSDN社区短信息,请莫浪费精力))
说说难道原始需求吧。要自己写streambuf的场合是很少很少的。



filebuf *fB;
int length;

fB=file.rdbuf();
length=fB->seekoff(0,ios::end,ios::in)-fB->seekoff(0,ios::beg,ios::in);
fB->seekoff(0,ios::beg,ios::in);

我是在看一本书的例子
这里是要求文件长度
taodm 2007-08-30
  • 打赏
  • 举报
回复
说说难道原始需求吧。要自己写streambuf的场合是很少很少的。
expter 2007-08-30
  • 打赏
  • 举报
回复
类的保护函数不能直接在外面调用
glgg 2007-08-30
  • 打赏
  • 举报
回复
该怎么解决呢?
我想写一个派生类,但是不知道语法
因为basic_filebuf的定义我看不懂,不知道该怎么从这个类派生

template<class _Elem,
class _Traits>
class basic_filebuf
: public basic_streambuf<_Elem, _Traits>
{ // stream buffer associated with a C strea
ouyh12345 2007-08-30
  • 打赏
  • 举报
回复
没用过。
出错提示是楼主使用了basic_filebuf类的保护函数。

64,654

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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