したがって、リンクされたリストが正しく作成され、適切にリンクされていますが、メモリの割り当てを解除しようとすると、ノードを削除できないように見えますが、リストはまだ存在しています。私のリストデコンストラクターのコード:
void LL_User::free_memory() {
// TODO
LL_User_Node *currentNode;
currentNode = head;
while(currentNode) {
LL_User_Node *temp = currentNode;
currentNode = currentNode->next;
delete temp;
}
//cout << "LL_User::free_memory() is not implemented yet.\n";
}
LL_User::~LL_User() {
if(head == NULL) {
return;
}
free_memory();
}
そして、私のユーザークラスには、変数とデコンストラクター用にこれがあります:
User::User() {
username = "";
password = "";
first_name = "";
last_name = "";
profile_pic_filename = "";
birth_year = 0;
birth_month = 0;
birth_day = 0;
}
User::~User() {
//Nothing placed in body because strings and ints are dealt with by OS?
}