MENU
Question -

Write the defintion of a member function PUSH () in C+ +, to add a new book in a dynamic stack of BOOKS considering the following code is already included in the program :

struct BOOKS
 {
 Char ISBN [20]; TITLE[80];
 BOOKS *Link;
 };
 class STACK
 {
 BOOKS *Top;
 public :
 STACK () {Top = NULL;}
 void PUSH ();
 Void POP ();
 -STACK ();
 };



Answer -

void STACK :: PUSH ()
 {
 BOOKS *Temp;
 Temp=New BOOKS;
 gets (Temp->ISBN);
 gets (Temp->TITLE);
 Temp->Link =Top;
 Top=Temp;
 }
OR
Any other correct equivalent function definition

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
Any questions? Ask us!
×