不懂为什么下面的能编译过,没搜到答案。

#include <bits/stdc++.h>
using namespace std;
int main()
{
    multiset<int> s;
    set<int>::iterator it = s.begin();
}

主动写下错误答案:
set和multiset都是rbtree包了一个壳,所谓iterator其实是rbtree的iterator。
所以只要set和multiset类型相同,迭代器是可以互相赋值的,使用上也不会出错。

map和multimap同理。

wwwwodddd Uncategorized

Leave a Reply

Your email address will not be published. Required fields are marked *