'std::vector<int>'中没有命名'set'的成员

no member named 'set' in 'std::vector<int>'

本文关键字:成员 set gt vector std lt int      更新时间:2023-10-16

我使用QT创建者和Xcode 4.63(osx-mav)

我刚打电话给.set(....),收到以下错误

no member named 'set' in 'std::vector<int, std::allocator<int> >

lib似乎有问题,因为我是QT创建者的新手,所以我仍然不知道如何纠正它。(我是c++新手)

#include <cctype>
#include <cmath>
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include "console.h"
#include "filelib.h"
#include "grid.h"
#include "gwindow.h"
#include "simpio.h"
#include "vector.h"
using namespace std;
int main() {
    vector<int> myVector(10,0);
    fstream mystream;
    string getStream;
    while(getline(mystream,getStream))  {
        getline(mystream,getStream);
        if(stringToInteger(getStream)>=0 && stringToInteger(getStream)<=9) {
            myVector.set(0,(myVector[0]+1))
        };
    }
    return 0;
};

STL中不存在向量的"set"方法。如果您想更改值,可以使用[]运算符:

myVector[0] = myVector[0] + 1;

甚至

myVector[0]++;