CBSE (Science) Class 12CBSE
Share
Notifications

View all notifications

Write the Definition 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 - CBSE (Science) Class 12 - Computer Science (C++)

Login
Create free account


      Forgot password?

Question

Write the definition 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();
};

Solution

void STACK::PUSH()
{
   BOOKS *Temp;
   Temp = new BOOKS;
   gets(Temp -­>ISBN);
   gets(Temp­ ->TITLE);
   Temp­->Link=Top;
   Top = Temp;
}
  Is there an error in this question or solution?

APPEARS IN

Solution Write the Definition 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 Concept: Member of a Class - Data Members and Member Functions (Methods).
S
View in app×