文章目录 使用iterator 今天重载map的输出,需要使用map作为函数参数。找到了一种解决办法,应该是一种通法,STL一般都可以这种方法作为函数参数。 使用iterator ostream& operator<<(ostream& os, const map<node, int>::iterator m) { os << m->first.first << ", " << m->first.second << ", " << m->second; return os; } node是我自定义的一个结构体。