Getting Union, Intersection, or Difference of Sets in C++

房东的猫 提交于 2019-12-04 05:11:47

Use the set_difference(), set_union(), set_intersection() and set_symmetric_difference() functions.

Sets and maps support any key type that can compare. By default this means the type has operator<() defined, but you can provide your own comparator. C++ sets don't have operator<() defined and therefore can't be used as keys unless you provide your own comparator.

As for your first question, have a look at

Anything can be used as a key in a map as long as you provide a class or function that can compare them. Here is an example.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!