您可以std::find用来获取值的迭代器:#include <algorithm>std::vector<int>::iterator position = std::find(myVector.begin(), myVector.end(), 8);if (position != myVector.end()) // == myVector.end() means the element was not found myVector.erase(position);