削除とデストラクタに問題があります(ここで愚かな間違いを犯していると確信していますが、現時点ではそれを理解できていません)。
デストラクタにステップスルーし、ポインタでdeleteを呼び出そうとすると、「アドレスのあるアドレスのメモリにアクセスできません」というメッセージが表示されます。
関連するコードは次のとおりです。
/*
* Removes the front item of the linked list and returns the value stored
* in that node.
*
* TODO - Throws an exception if the list is empty
*/
std::string LinkedList::RemoveFront()
{
LinkedListNode *n = pHead->GetNext(); // the node we are removing
std::string rtnData = n->GetData(); // the data to return
// un-hook the node from the linked list
pHead->SetNext(n->GetNext());
n->GetNext()->SetPrev(pHead);
// delete the node
delete n;
n=0;
size--;
return rtnData;
}
と
/*
* Destructor for a linked node.
*
* Deletes all the dynamically allocated memory, and sets those pointers to 0.
*/
LinkedListNode::~LinkedListNode()
{
delete pNext; // This is where the error pops up
delete pPrev;
pNext=0;
pPrev=0;
}