• 欢迎浏览“String me = Creater\忠实的资深Linux玩家;”,请文明浏览,理性发言,有侵犯你的权益请邮件我(creater@vip.qq.com).
  • 把任何的失败都当作一次尝试,不要自卑;把所有的成功都想成是一种幸运,不要自傲。
  •    5年前 (2013-06-12)  Linux |   5 条评论  21 
    文章评分 0 次,平均分 0.0

    先来看看原型:

    streambuf* rdbuf ( ) const;
    streambuf* rdbuf ( streambuf* sb );

    再来看看cplusplus上面的描述

    The first form (1) returns a pointer to the stream buffer object currently associated with the stream.
    
    The second form (2) also sets the object pointed by sb as the stream buffer associated with the stream and clears the error state flags.
    
    If sb is a null pointer, the function automatically sets the badbit error state flags (which may throw an exception if member exceptions has been passed badbit).
    
    Some derived stream classes (such as stringstream and fstream) maintain their own internal stream buffer, to which they are associated on construction. Calling this function to change the associated stream buffer shall have no effect on that internal stream buffer: the stream will have an associated stream buffer which is different from its internal stream buffer (although input/output operations on streams always use the associated stream buffer, as returned by this member function).

    像stringstream和fstream这样的派生类拥有自己的内部缓冲区,是在对象构造时就分配。调用函数streambuf* rdbuf ( streambuf* sb )将不会对内部缓冲区有作用。

     

    除特别注明外,本站所有文章均为String me = "Creater\忠实的资深Linux玩家";原创,转载请注明出处来自http://unix8.net/home.php/1489.html

    关于

    发表评论

    暂无评论

    切换注册

    登录

    忘记密码 ?

    切换登录

    注册

    扫一扫二维码分享