comparedValuesBetween2

comparedValuesBetween2

我正在尝试删除由if语句定义的特定值,然后将其存储为一个int,然后我想查看向量并通过使用擦除它

if (comparedValuesBetween2[i] == First0ValueFor0Number2[j])
{
    //make sure if there are no values to compare left just leave the the while loop by editing the count.
    comparedValuesBetween2.resize(std::remove(comparedValuesBetween2.begin(), comparedValuesBetween2.end(), 8) - comparedValuesBetween2.begin());
 }


但即时通讯收到这些错误,我不知道为什么能帮助您


  6 IntelliSense: too many arguments in function call g:\08227 acw\ACW\Sudoku\Sudoku\main.cpp 225
  
  5 IntelliSense: no suitable conversion function from "std::_Vector_iterator<std::_Vector_val<std::_Simple_types<int>>>" to "const char *" exists g:\08227 acw\ACW\Sudoku\Sudoku\main.cpp 225


我是C ++的新手。谢谢你的帮助。

最佳答案

您可以简单地调用std::vector::erase()从容器中删除指定的元素:

if (comparedValuesBetween2[i] == First0ValueFor0Number2[j])
    comparedValuesBetween2.erase(comparedValuesBetween2.begin() + i);

关于c++ - std::移除指定元素的 vector ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23298036/

10-12 07:09