MENU
Question -

Write the definition of a member function Pop ()
in C++, to delete a book from a dynamic stack of TEXTBOOKS considering the following code is already included in the program.

Struct TEXTBOOKS
 {
 Char ISBN [20]; Char TITLE [80]; TEXTBOOKS *Link;
 };
 class STACK
 {
 TEXTBOOKS *Top; 

public :
 STACK () {Top = NULL;} 

void Push ();
 . void pop );
 -STACK ();
 };



Answer -

void STACK : : POP ()
 {
 if (Top ! = NULL)
{
 TEXTBOOKS *Temp;
 Temp=Top;
cout<< TOP- >ISBN<
 TITLE<<"delected"<
 Top=Top-Link;
 delete Temp;
 }
 else
 cout<<"Stack Empty"<
 }
OR
Any other correct equivalent function definition

Comment(S)

Show all Coment

Leave a Comment

×