ostream类重载了operator<<()以识别不同的类型,如: int short long unsigned int unsigned short unsigned long float double long double char signed char unsigned char 这样cout就不用像C语言中的printf那样需要程序员自行匹配数据类型,如:printf("%s%d%f","hello world",32,3.
众所周知,map有find,但vector的find只能调用algorithm中的find通用方法. 参考<How to find an item in a std::vector?> 对于结构体来说,如何定义==呢? 想到了重载==操作符,通常的情形是重载相同类型,在例子中,我重载了int类型的. 结果也过了,感觉很请强大,具体参考如下代价 #include <vector> #include <algorithm> using namespace std; stru