cout2


#include <stdio.h>

class MyOut
{
public:
    const MyOut& operator<<(int value) const
    {
        printf("%d", value);
        return *this;
    }

    const MyOut& operator<<(char *value) const
    {
        printf("%s", value);
        return *this;
    }
};

MyOut out;

int main()
{
    char str[] = "HelloWorld\n";
    int a = 10;
    out << str << a;
    return 0;
}


posted @ 2017-11-16 20:44  目瞪狗呆  阅读(86)  评论(0)    收藏  举报