cout

 1 #include <stdio.h>
 2 
 3 class MyOut
 4 {
 5 public:
 6     const MyOut& operator<<(int value) const
 7     {
 8         printf("%d", value);
 9         return *this;
10     }
11 
12     const MyOut& operator<<(char *value) const
13     {
14         printf("%s", value);
15         return *this;
16     }
17 };
18 
19 MyOut out;
20 
21 int main()
22 {
23     char str[] = "HelloWorld\n";
24     int a = 10;
25     out << str << a;
26     return 0;
27 }

 

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