Skip to main content

All Questions

Tagged with
1 vote
1 answer
121 views

Reverse while iteration not going backwards

I am trying to make a reverse loop through a list using while. I am trying the following code: #include <iostream> #include <list> int main(){ std::list <int> l1 = {1,2,3,4}...
user avatar
1 vote
1 answer
87 views

MFC ListControl functions Slowing everything down

I am developing a C++ MFC-based application that takes positional data over IP, does some stuff, sends it back over IP, then outputs it to the list control. Every packet is collected, processed and ...
LazyBear's user avatar
  • 353
0 votes
0 answers
58 views

Unexpected double free in single linked list

`I am trying to do a simple linked list. Everything works fine, but after the program calls ~List() I am getting "double free in tcache2" and SIGABRT every time I run the program and ...
Juliusz Bednarek's user avatar
-1 votes
2 answers
67 views

Polymorphic behavior of derived class objects in C++ STL list [duplicate]

I am storing objects of base and derives classes (Account, StudentAccount, EmployeeAccount) in an STL list and process them with STL Iterator. The dynamic polymorphic behavior of objects is not ...
Syed Irfan Ahmad's user avatar
-2 votes
3 answers
77 views

Why isn't my list adding the final node after the carry?

I am currently attempting to answer the question Add Two Numbers from leetcode, my solution seems to function as I expect however in cases where my final carry int is needed it is not added to the end ...
ick1salvado's user avatar
0 votes
1 answer
144 views

How to remove a `std::thread` from a container when it's finished?

There is a std::list<std::thread> in a class with another thread which can add some. How to handle the responsibility to remove a thread element from the list when it's finished ? I thought ...
coucou's user avatar
  • 1
0 votes
1 answer
126 views

C++ Why do std::vector<> and std::list<> not share a common base class/interface?

Since im mainly working on C#. After quite some time a had to work on a C++ project and was wondering why C++ isn't relying on inheritance or interfaces for related methods such as std::vector<>:...
Jan Wiesemann's user avatar
0 votes
1 answer
62 views

Why my code is working on everything except one instance?

I do homework for my lab on c++, I needed to get a number from keyboard and delete an element after inputted number in STL list. For some reason if I get 7 elements into the list, exactly {1,2,2,3,4,2,...
Orkhan Mirzoev's user avatar
0 votes
0 answers
53 views

Why does VS Code give me this error? : non-aggregate type 'list<int>' cannot be initialized with an initializer listgcc [duplicate]

Currently writing a very basic C++ program to practice some data structures. I had no problem implementing a queue function but when it came to initializing a list, VS Code spat back an error I can't ...
AB Luna's user avatar
-1 votes
1 answer
55 views

Pass function as function parameter to order linked list

I'm writing a program that provides the tools to create and manipulate a linked list. I've already finished the methods to add, delete nodes, etc. However, in order to create the method that orders ...
Juan Felipe Rubiano's user avatar
0 votes
1 answer
89 views

std::list.erase() seems to be rearranging the elements of the list

Consider the following function void removeOdd(list<int>& li) { for(list<int>::iterator it=li.begin(); it!=li.end(); it++) { if((*it)%2) it = li.erase(it); } } ...
Teong Seng Tan's user avatar
0 votes
0 answers
84 views

Can't properly empty out a list due to "cannot increment end list iterator"

I'm trying to figure out why accessing the next-to-last item in a linked list keeps crashing the program. My actual goal is to safely delete the last item of the list without a memory/iterator crash. ...
Glatisant Soldier's user avatar
0 votes
1 answer
59 views

Why doesn't this implementation of LRU cache work?

I encountered this problem on LeetCode, which needs us to implement the LRU cache functions "get" and "put" in O(1) average time complexity. I tried the similar method here, in ...
吳承宇's user avatar
-1 votes
3 answers
178 views

How do I get the last number to create a new line?

I am working on a lab for a C++ course. My current code gives me most but not all points available for this lab. I can't quite seem to get the code to print correctly. I've tried many possible ways of ...
Canadian Gamer's user avatar
4 votes
3 answers
241 views

The end iterator for a linked list

I started to implement a list and got stuck at the end() iterator function. My understanding is that end() should point one element after the last member of the list. But since in a list elements are ...
KcFnMi's user avatar
  • 6,139

15 30 50 per page
1
2 3 4 5
193