Linked Questions

0 votes
2 answers
273 views

I have a vector of class objects (bullets) and it works for the most part. But as soon as I try to delete the bullets it loops back and then causes a breakpoint. "basic game.exe has triggered a ...
Mitchell's user avatar
0 votes
1 answer
1k views

When iterating through an STL::vector of pointers, what is the best practice for deleting objects along the way? I understand the erase-remove idiom. But since the vector contains pointers, I am ...
M F's user avatar
  • 37
0 votes
1 answer
525 views

Why am I getting a Vector iterator is not incrementable error in this code? for (vector<vector<Point>>::iterator it = contours.begin(); it != contours.end(); ++it) { if (contourArea(*...
Matt's user avatar
  • 2,350
-2 votes
1 answer
315 views

I am iterating through a map which has the vector as the V parameter map<SomeKey, vector<shared_ptr<SomeObject>> I am iterating over to remove all instances of SomeObject contained in ...
jjmcc's user avatar
  • 905
0 votes
0 answers
162 views

im new to C++. I want to know how to erase an element from a vector passed by reference, where the value of Length (function of my Vector3D object) returned is less than the int parameter passed to ...
user avatar
1 vote
0 answers
127 views

I have this code I made up to explain my problem: #include <iostream> #include <vector> void PrintVector (const std::vector<int> & vec) { std::cout << "vector contains:...
Steve B.'s user avatar
-2 votes
1 answer
94 views

How can i remove matched elements in c++ while keeping the same order ? i found similar question here but they sort the elements while i want to keep the order for example i have v1{1,2,3,4} , v2{8,6,...
Farah's user avatar
  • 1
126 votes
7 answers
179k views

I want to clear a element from a vector using the erase method. But the problem here is that the element is not guaranteed to occur only once in the vector. It may be present multiple times and I need ...
Naveen's user avatar
  • 73.8k
0 votes
4 answers
573 views

I have a for loop that iterates through a vector of objects. If an object doesn't meet a condition, I would like to reiterate the same object through the loop until it meets the condition. int ...
ATL_DEV's user avatar
  • 9,658
2 votes
2 answers
2k views

The following C++ code seems to work, and I'm curious to learn how: std::map<char,char> mymap; mymap['a'] = 'A'; mymap['b'] = 'B'; mymap['c'] = 'C'; mymap['d'] = 'D'; mymap['e'] = 'E'...
frankelot's user avatar
  • 14.5k
-1 votes
3 answers
3k views

I'm tasked with creating a vector of 'x' numbers and finding the prime numbers in that vector using the "Sieve of Eratosthenes." I iterated through the vector to replace all of the non-prime elements ...
caffeinatedkomodo's user avatar
0 votes
1 answer
4k views

I am trying to write this code but this is giving the error No matching member function for call to 'erase'clang(ovl_no_viable_member_function_in_call) stl_vector.h(1317, 7): Candidate function not ...
Dj Agor's user avatar
  • 13
4 votes
2 answers
2k views

I am manipulating vectors of objects defined as follow: class Hyp{ public: int x; int y; double wFactor; double hFactor; char shapeNum; double* visibleShape; int xmin, xmax, ymin, ymax; Hyp(int xx,...
matt's user avatar
  • 87
0 votes
2 answers
1k views

In this code snippet Update() returns a boolean, if it returns false I would like to delete the element from the vector. However, this produces a run-time error of debug assertion failed. The ...
OMGtechy's user avatar
  • 8,380
1 vote
2 answers
2k views

I'm trying to erase the last element in the vector using iterator. But I'm getting segmentation fault when erasing the element. Below is my code: for (vector<AccDetails>::iterator itr = ...
Joel Seah's user avatar
  • 726

15 30 50 per page