有没有更简单的方法使用 C++ 将数组转换为集合而不是循环遍历其元素?
最好使用标准模板库
对于所有标准库容器类型,请使用构造函数 http://en.cppreference.com/w/cpp/container/set/set:
std::set<T> set(begin(array), end(array));