Whenever I try to delete one the elements for my HashMap, I get an error in the C++ code (not my code...the C++ people's code - specifically, xmemory0). I am sure the error is on my end, but I have no clue where, since the debugger is telling me its elsewhere. My HashMap has been thoroughly tested, and it seems to function fine except for when I try to delete a HashElement. I am pretty sure that nothing is pointing to a HashElement before I delete it (which I think would be the first guess). Can anyone tell why I am getting an error when I try to delete the HashElement? Here is my stack trace:
msvcr120d.dll!operator delete(void *) Unknown
> MyProgram.exe!std::allocator<char>::deallocate(char * _Ptr, unsigned int __formal) Line 573 C++
MyProgram.exe!std::_Wrap_alloc<std::allocator<char> >::deallocate(char * _Ptr, unsigned int _Count) Line 859 C++
MyProgram.exe!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Tidy(bool _Built, unsigned int _Newsize) Line 2284 C++
MyProgram.exe!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::~basic_string<char,std::char_traits<char>,std::allocator<char> >() Line 992 C++
MyProgram.exe!HashElement::~HashElement() Line 12 C++
Here is the code:
HashElement.h
#pragma once
#include <string>
class HashElement
{
private:
int key_;
std::string value_;
public:
HashElement(int, std::string);
~HashElement();
HashElement *next_element_;
int GetKey();
std::string GetValue();
};
HashElement.cpp
#include "HashElement.h"
HashElement::HashElement(int key, std::string value)
{
key_ = key;
value_ = value;
next_element_ = nullptr;
}
HashElement::~HashElement()
{
} //This is the last line before it goes off into not my code
int HashElement::GetKey(){
return key_;
}
std::string HashElement::GetValue(){
return value_;
}
I will happily post the HashMap itself as well, but I don't think the error is related to the actual HashMap code, so I will leave it out for now to make this post more readable.
Aucun commentaire:
Enregistrer un commentaire