How to put stack in my coding ? i want to pop the values that i already insert by linked list

#include<iostream>
#include<string>
#include <iomanip>
using namespace std;

class nodeStack
{
int data;
nodeStack *next;
};

class Library{
public:
int ISBN;
string title;
string author;
Library *next;
Library(int ISBN, string title, string author, Library* b=NULL)
{
this -> ISBN = ISBN;
this -> title = title;
this -> author = author;
this -> next = b;
}
};

class Book
{
private:
Library *head,*tail;
nodeStack* top;

public:
Book();
~Book();
void addBook();
void delBook();
void searchBook();
void createStack();
void push(int, string, string);
void sortBook();
void popBook();
void display();
};

Book::Book(){

head = tail = NULL;
}
Book::~Book(){

Library* p = head,*q = head;
while(p != NULL)
{
q = head -> next;
delete p;
p = q;
}
}
void Book::addBook(){

int ISBN;
string title, author;
cout << "\nEnter the ISBN:";
cin >> ISBN;
cout << "Enter the title:";
cin >> title;
cout << "Enter the author:";
cin >> author;

if(head == NULL)
{
head = tail =new Library(ISBN, title, author);
cout << "\nYou have add this book....\n" << endl;
cout << "\nThe new book list update\n" << endl;
return;
}
else
{
Library *p = head;
while(p -> next)
{
if(title <p-> title)
break;
else
p = p -> next;

}
p -> next = new Library(ISBN, title, author, p->next);

cout << "\nYou have add this book....\n" << endl;
cout << "\nThe new book list update\n" << endl;
return;
}
}
void Book::delBook(){

int ISBN;
string title, author;
cout << "\nEnter the ISBN:";
cin >> ISBN;
cout << "Enter the title:";
cin >> title;
cout << "Enter the author:";
cin >> author;

Library *p=head, *q=head;
if((p -> ISBN == ISBN) && (p -> title == title) && (p -> author == author))
{
head = head -> next;
cout << "\nYou have delete that book...\n" << endl;
delete p;
return;
}
p = head -> next;
while(p)
{
if((p -> ISBN == ISBN) && (p -> title == title) && (p -> author == author))
{
q -> next = p -> next;
delete p;
cout << "\nYou have delete that book...\n" << endl;
return;
}
else
{
q = p;
p = p -> next;
}
}
cout << "\nThe new book list update\n" << endl;
return;
}
void Book::searchBook(){

string title;
cout << "\nEnter the title: ";
cin >> title;
Library* p = head;
while(p != NULL)
{
if(p -> title == title)
{
cout << "\nThe ISBN: " << p -> ISBN << "\nWritter : " << p -> author << endl << endl;
return;
}
else
p = p -> next;
}
cout << "\nThe new book list update\n" << endl;
return;
}


void Book::createStack();
{
top = NULL;
}

void Book::push(int ISBN, string title, string author)
{

void Book::sortBook(){


}
void Book::popBook()
{

}

}
void Book::display()
{
Library* p=head;
cout << "\nThe new book list\n" << endl;
while(p!=NULL)
{
cout << "\nThe ISBN: " << p -> ISBN << "\nTitle: " << p-> title << "\nWritter: " << p -> author;
p = p -> next;
cout << endl;
}
cout<<endl;
}
int main(){

Book t;
while(true)
{
cout << " Library Management System" << endl;
cout << " ==============================================" << endl;
cout << " ||\t bil \t|| Action ||" << endl;
cout << " ==============================================" << endl;
cout << " ||\t 1 \t|| Add Book ||" << endl;
cout << " ||\t 2 \t|| Delete Book ||" << endl;
cout << " ||\t 3 \t|| Search Book ||" << endl;
cout << " ||\t 4 \t|| Arrange Book ||" << endl;
cout << " ||\t 5 \t|| Review New Book ||" << endl;
cout << " ||\t 6 \t|| Display All Book ||" << endl;
cout << " ||\t 7 \t|| Exit ||" << endl;
cout << " ==============================================" << endl;

cout << "Enter your choice:";
int option;
cin >> option;
switch(option)
{
case 1:
t.addBook();
break;
case 2:
t.delBook();
break;
case 3:
t.searchBook();
break;
case 4:
t.sortBook();
break;
case 5:
t.popBook();
break;
case 6:
t.display();
break;
case 7:
return 0;

default:
cout << "Thank you"<<endl;
break;
}
}
return 0;
}
Topic archived. No new replies allowed.