Я пытаюсь создать программу списка дел. Я пытаюсь распечатать мои задачи списка задач, затем распечатать опции для пользователя. Проблема в том, что после использования функции класса списка ".display ()" что приходит после того, как это игнорируется. Также первый созданный мной узел не учитывается при попытке распечатать список.
это основной. cpp.
#include <iostream>
#include <string>
#include <fstream>
#include "node.h"
using namespace std;
int main(void)
{
list m;
m.createnode(0, 0, 0, "", "");
m.createnode(1, 1, 1, "j", "j");
m.createnode(1, 1, 1, "j", "j");
m.display();
cout << "1.choose task";
return 0;
}
это node.h (класс списка)
#include <string>
#include <stdlib.h>
#include <windows.h>
using namespace std;
typedef struct node {
std::string name;
std::string task;
int due_date[3];
bool done;
node*next;
}m;
class list
{
private:
node head ,tail;
public:
list()
{
head = NULL;
tail = NULL;
}
void createnode(int d, int m, int y, std::string task, std::string name)
{
node *temp = new node;
temp->due_date[0] = d;
temp->due_date[1] = m;
temp->due_date[2] = y;
temp->task = task;
temp->name = name;
temp->done = false;
temp->next = NULL;
if (head == NULL)
{
head = temp;
tail = temp;
temp = NULL;
}
else
{
tail->next = temp;
tail = temp;
}
}
void display()
{
node *temp = new node;
temp = head;
tail = NULL;
while (temp != NULL)
{
temp = temp->next;
cout << temp->name << "\n";
cout << temp->due_date[0] << "/" << temp->due_date[1] << "/" << temp->due_date[2] << "\n";
cout << "description: ";
cout << temp->task << "\n";
cout << "status: ";
if (temp->done == false)
{
cout << "incomplete"<<"\n";
}
else {
cout << "complete"<<"\n";
}
cout << "";
}
}
};