so i have some code that ive been working on, and dare i say, understanding, involving linked lists, only i've hit a wall
I need to add a new structure, called date, so that a day, month, and year, are associated with every node, for rolls, jam, and tea, and then there is a specific "expiration date" associated with each
heres the code
#include "stdafx.h"
#include <iostream>
#include <cstddef>
#include <string>
using namespace std;
struct Node
{
string item;
int count;
Node *link;
};
typedef Node* NodePtr;
void head_insert(NodePtr& head, string an_item, int a_number);
void show_list(NodePtr& head);
int main()
{
NodePtr head = NULL;
head_insert(head, "Tea", 2);
head_insert(head, "Jam", 3);
head_insert(head, "Rolls", 10);
show_list(head);
return 0;
}
void head_insert(NodePtr& head, string an_item, int a_number)
{
NodePtr temp_ptr;
temp_ptr = new Node;
temp_ptr-> item = an_item;
temp_ptr-> count = a_number;
temp_ptr->link = head;
head = temp_ptr;
}
void show_list(NodePtr& head)
{
NodePtr here = head;
while (here != NULL)
{
cout << here-> item << "\t";
cout << here-> count << endl;
here = here->link;
}
}
i somewhat understand the syntax to add in a new structure
but then having to put in the expiration dates...day month and year...how would i declare those? ints? doubles?