We have this final project and we are required to make a program using trees, linked lists, and file streaming.I have a few questions in mind with the construction of our program. By the way, we are constructing a Library Management System program where in we could add students(and also their information) in a node using linked lists and then copy the information in a text file. We are required to search a book or a student and also edit the information. But then, i don't know if I can make a structure inside the structure of the node. I tried it once, but I can't apply the void LibraryManagement::addstudent()and input the user defined information like name, ID number, year/course, etc. So my first question is : Can i make another structure inside the structure of a node.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#include <string>
#include <cstdlib>
#include<fstream>
#include<stdio.h>
#include<process.h>
#include<string.h>
#include<iomanip>
using namespace std;
/*--------------------------------------*/
/*---------Students class---------------*/
/*--------------------------------------*/
class Students{
private:
typedef struct nodeS{
struct details;
nodeS* next;
nodeS* prev;
};
struct details{string Sname;
string idno;
string year;
string bb; };
nodeS* head;
nodeS* last;
public:
Students(){
head=NULL;
last=NULL;
}
bool empty()const{return head==NULL;}
friend ostream& operator<<(ostream&, const Students&);
void addstudent(const struct details& a);
void removestudent(const string& a, string& s, string& d, string& f);
|
but with that, the void addstudent(const struct details& a) showed with a red underline.
My second question is: can I make a tree inside a node, then call the information or the value in the node using the key in hashing? Well, the the tree should compose the Book title(root node), author of the book (child), ISBN(child), quantity of the book(child of the author, because i only wanted a binary tree) Then I will use the key by the ISBN of the book.
My last question is about file streaming. I planned of doing this for adding a student. I don't know if this is possible but this is how it goes:
For adding a student in the list:
-open the student.txt
-the entered information should be copied to the .txt file then also copied to the structure of the node specifically the name, id number, year/course etc.
Then close the file. Do you think this is possible?
Thank you for reading, hoping for answers :)