本文介绍了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 allowedto maintain separate pointers for input and output: fstreamdoesn't, but stringstream does. So you need either a flag toindicate which one you want (as is the case in streambuf), oryou need two separate functions.

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

10-11 12:53