0

这个问题与我之前的问题有关。我使用下面的代码来检查与streambuf关联的对象中的值cout。使用VS2010 IDE,我可以看到这个类的几个成员。谁能指出我这些成员中的哪一个指向内存中 cout 的空缓冲区?

#include <iostream>

int main()
{
    std::streambuf* p = std::cout.rdbuf();  
}

编辑:查看streambuf头文件可以在类中找到以下私有成员basic_streambuf

    _Mutex _Mylock; // thread lock
    _Elem *_Gfirst; // beginning of read buffer
    _Elem *_Pfirst; // beginning of write buffer
    _Elem **_IGfirst;   // pointer to beginning of read buffer
    _Elem **_IPfirst;   // pointer to beginning of write buffer
    _Elem *_Gnext;  // current position in read buffer
    _Elem *_Pnext;  // current position in write buffer
    _Elem **_IGnext;    // pointer to current position in read buffer
    _Elem **_IPnext;    // pointer to current position in write buffer

    int _Gcount;    // length of read buffer
    int _Pcount;    // length of write buffer
    int *_IGcount;  // pointer to length of read buffer
    int *_IPcount;  // pointer to length of write buffer

    locale *_Plocale;   // pointer to imbued locale object

我相信_Pfirst这是我正在寻找的地址,它是 NULL 正如预期的那样。

4

0 回答 0