but i get a no registers fault as it tries to leave the function every time. The error occurs at the last }.
I am really lost. Can anyone explain what I should be looking for or help me find out what I am doing wrong. I can post more of the code on request.
How was VF defined? Also you are trying to access your ResultVector and Blank vectors out of bounds. When you declared these vectors you created three elements, but you are trying to access element 4. Remember in C++ arrays and vectors are zero based so the valid elements are 0 to size -1.
I have changed the code to reflect the correct indecies and it appears to work. Thank you so much for the help.
P.S. VF was a vector<double> passed into the function (I think i did it right) by reference.
I am running into that problem now. How can i correct that. I don't really understand the difference in syntax for the two, though I think I understand what each is conceptually supposed to do. Thanks for you help.
One last question if anyone wants to answer it. I have come up on another problem that relates to my lack of understanding in vectors.
In the following, it runs fine up until I get to dropping the obtained value into FinalList. At this point it has problems. I believe this is because the vector FinalList has no size, so the position 0,0 doesn't technically exist. My question is, as I do not know how long the final size will need to be, and the operator will likely now know either, how can I re size it to expand by 1 row of 3 units each time I drop data into it? I have been reading about resize, but I am still unclear on the syntax to use. Thanks
I believe this is because the vector FinalList has no size,
That is correct. When dealing with vectors the element must exist before you can assign a value to an element. To do this you usually use the push_back() method or initialize the vector with the size parameter.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
std::vector<int> mints; // Create a vector of ints.
// Now add some elements with the push_back() method.
std::vector<std::vector<int>> m2dints; // Create an empty vector vector int.
// Now add an element to this vector. This vector will now contain one vector<int>, that has 3 elements.
// Now add another element to the mints vector.
// Now add another element to the 2d vector. Now there will be two elements in this 2d vector that contain
// 3 and 4 elements.