basic_istream<> :: tellg()和basic_ostream<> :: tellp()之间的差异 [英] Difference between basic_istream<>::tellg() and basic_ostream<>::tellp()

查看:75
本文介绍了basic_istream<> :: tellg()和basic_ostream<> :: tellp()之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道为什么basic_istream<>类中定义的成员函数tellg()basic_ostream<>类中定义的tellp()具有不同的名称.那是因为basic_fstream<>是从basic_istream<>basic_ostream<>派生的吗?

I was just wondering why the member functions tellg() defined in basic_istream<> class and tellp() defined in basic_ostream<> class have different names. Is that because basic_fstream<> is derived from basic_istream<> and basic_ostream<> ?

推荐答案

以及如何在双向流中区分它们, 例如std::fstreamstd::stringstream?允许流 维护输入和输出的单独指针:fstream 不会,但是stringstream会.所以你需要一个标志 指出您想要的那个(例如streambuf),或者 您需要两个单独的功能.

And how would you distinguish them in bidirectional streams, like std::fstream or std::stringstream? Streams are allowed to maintain separate pointers for input and output: fstream doesn't, but stringstream does. So you need either a flag to indicate which one you want (as is the case in streambuf), or you need two separate functions.

这篇关于basic_istream&lt;&gt; :: tellg()和basic_ostream&lt;&gt; :: tellp()之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆