[008]C/C++ | cout 源碼

一、源碼

class _IO_ostream_withassign
    : public ostream {
    ...
};

extern __IO_ostream_withassign cout;

cout主要是繼承ostream!!!

二、ostream源碼

class ostream : virtual ios
{
    public:
        ostream& operator<<(char c);
        ostream& operator<<(unsigned char c) { return (*this) << (char)c }
        ostream& operator<<(signed char c) { return (*this) << (char)c; }
        ostream& operator<<(const char *s);
        ostream& operator<<(const unsigned char *s)
               { return (*this) << (const char*)s; }
        ostream& operator<<(const signed char *s)
               { return (*this) << (const char*)s; }
        ostream& operator<<(const void *p);
        ostream& operator<<(int n);
        ostream& operator<<(unsigned int n);
        ostream& operator<<(long n);
        ostream& operator<<(unsigned long n);
        ...
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章