标签:operator print opera hello std str include bsp const
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 }
标签:operator print opera hello std str include bsp const
原文地址:http://www.cnblogs.com/nosit/p/7846285.html