Linked Questions

2 votes
6 answers
219 views

while debugging a vector, I see an inconsistency. Assume the following code which tries to remove an entry from a vector which has only one element #include <iostream> #include <vector> ...
mahmood's user avatar
  • 25.2k
2 votes
3 answers
248 views

I use a vector of shared pointers to contain some game characters called customer. typedef std::shared_ptr<Customer> customer; std::vector<customer> customers; customers.push_back(...
Chris's user avatar
  • 191
-1 votes
1 answer
109 views

I'm removing duplicate integers from the vector; the loop I made is working as intended, but only if I add Break; inside the ' if ' statement, or it will give wrong output. Can someone explain why is ...
Maamar Darmech's user avatar
-1 votes
1 answer
78 views

So I have simple JSON string that I'm iterating through with a for loop (don't ask why I'm not using a json parser). In this loop I want to kick out {, } and '' (the misplaced } is just there for ...
alektron's user avatar
2 votes
4 answers
3k views

I thought the following code would work but it crashes when the target widget is at the end of the vector. for(std::vector<AguiWidget*>::iterator it = children.begin(); it != children....
jmasterx's user avatar
  • 54.5k
4 votes
1 answer
8k views

This question clearly articulates how to move contents from one std::vector to another. In short, there is a std::move call required to physically move the memory, while there is also a std::erase ...
marcman's user avatar
  • 3,403
-5 votes
4 answers
891 views

This is the edited code vector<vector<int> > vec; vector<vector<int> >::iterator vit; vector<int>::iterator it; for ( vit = vec.begin(); vit != vec.end(); ++vit) { ...
Raghu G's user avatar
  • 97
0 votes
1 answer
2k views

When removing the given elements from the given array, I keep getting an error. This is my code, I am not sure where I the error is: int removeElement(vector<int>& nums, int val) { ...
Sanket Umredkar's user avatar
-1 votes
1 answer
753 views

I just recently started experimenting with vectors and I keep running into this problem when erasing a spot in the vector. Once it executes the erase() function it causes the application to crash and ...
Bryce910's user avatar
0 votes
0 answers
692 views

I cannot for the life of me figure out this error Access violation reading location 0x00000088, I am programming a script that controls the leds on my keyboard, and this error pops up after only about ...
YOUR WORST TACO's user avatar
1 vote
3 answers
111 views

for (Shape *i : shapes) { for (Shape *j : shapes) { if (i != j) { if (check(i,j)){ shapes.erase(remove(shapes.begin(), shapes.end(), i), shapes.end()); this ...
user1234's user avatar
1 vote
1 answer
47 views

I am working on a game for my University project and came across a problem with pointers. I have a vector of bullets that has every bullet checked for collisions. But, when I try to spawn 5 bullets at ...
Ivan's user avatar
  • 11