This line:
vector <float> vectorname;
vector <float> vectorname;
To copy to clipboard, switch view to plain text mode
Creates an empty vector of floats (and you try to access the first of them)
If you create empty vector you can use the push_back(...) member function to add elements to that vector
Or use it like this:
vector <float> vectorname(10); //this construct a vector of floats with 10 elements
vector <float> vectorname(10); //this construct a vector of floats with 10 elements
To copy to clipboard, switch view to plain text mode
Some documentation for std::vector
Note that the operator[] doesn't check if the number you write there is in vectorname range, you have to make sure that you "stay" in range (else you get an error), you have the at() member function that checks that.
Or you can use QVector instead, documentation for QVector or QList
Bookmarks