Original Post
Hello,
I'm feeling that this is a very stupid problem on my part, but I just could not for the life of me figure it out in over a week now =\
I have a class called Event, and that has a member vector commandList. Now, when I call the copy constructor, I want the commandList from the input to be copied to the new class.
So far I tried various ways:
I tried using substrings, inserts, assigns and so many other ways, I even tried making a new string vector inside the ctor, just to check if the problem is with the source or target, but that works, the problem seems to be with the target vector, to weird thing is that it will start copying the members, but it'll give the error somewhere midway along the loop, if I had 39 objects, it will always crash at 28, for example, even though the capacity is already set to 39...
Whatever I tried, it will ALWAYS end up in the heap corruption error message
I'm feeling that this is a very stupid problem on my part, but I just could not for the life of me figure it out in over a week now =\
I have a class called Event, and that has a member vector
So far I tried various ways:
Event::Event(const Event& it){
this->commandList = it.commandList;
}Event::Event(const Event& it){
//Both with and without this->commandList.reserve(it.commandList.size());
for(unsigned int i = 0; i < it.commandList; ++i){
this->commandList.push_back(it.commandList);
}
}Event::Event(const Event& it){
this->commandList.resize(it.commandList.size());
for(unsigned int i = 0; i < it.commandList; ++i){
this->commandList = it.commandList;
}
}I tried using substrings, inserts, assigns and so many other ways, I even tried making a new string vector inside the ctor, just to check if the problem is with the source or target, but that works, the problem seems to be with the target vector, to weird thing is that it will start copying the members, but it'll give the error somewhere midway along the loop, if I had 39 objects, it will always crash at 28, for example, even though the capacity is already set to 39...
Whatever I tried, it will ALWAYS end up in the heap corruption error message
[size="1"]HEAP[GameEngine.exe]: HEAP: Free Heap block 3f9350 modified at 3f9d64 after it was freed
Windows has triggered a breakpoint in GameEngine.exe.
This may be due to a corruption of the heap, which indicates a bug in GameEngine.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while GameEngine.exe has focus.
The output window may have more diagnostic information.
HEAP[GameEngine.exe]: HEAP: Free Heap block 3f9d68 modified at 3fb118 after it was freed
Windows has triggered a breakpoint in GameEngine.exe.
This may be due to a corruption of the heap, which indicates a bug in GameEngine.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while GameEngine.exe has focus.
The output window may have more diagnostic information.
[/quote]
I'm just lost for ideas by this point, and I hope that someone can help me shed light on this =\