无法将集合的元素插入到 C++ 中的向量中
Fail to insert the element of the set to the vector in c++
给定一组整数:
set<int> setA = {1,2,3,4,5};
现在我想在特定条件下将整数插入到整数向量中:
vector<int> vectorB;
for (set<int>::iterator it = setA.begin(); it != setB.end(); it++){
if (*it % 2 == 0){
}else{
vectorB.insert((*it));
count += 1;
}
}
但是我得到一个错误:
error: no matching function for call to 'std::vector<int>::insert(const int&)'
为什么?
给定一组整数:
set<int> setA = {1,2,3,4,5};
现在我想在特定条件下将整数插入到整数向量中:
vector<int> vectorB;
for (set<int>::iterator it = setA.begin(); it != setB.end(); it++){
if (*it % 2 == 0){
}else{
vectorB.insert((*it));
count += 1;
}
}
但是我得到一个错误:
error: no matching function for call to 'std::vector<int>::insert(const int&)'
为什么?