Advertisement Remove all ads

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 - Computer Science (C++)

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();
};
Advertisement Remove all ads

Solution

void STACK::PUSH()
{
   BOOKS *Temp;
   Temp = new BOOKS;
   gets(Temp -­>ISBN);
   gets(Temp­ ->TITLE);
   Temp­->Link=Top;
   Top = Temp;
}
Concept: Member of a Class - Data Members and Member Functions (Methods)
  Is there an error in this question or solution?
Advertisement Remove all ads
Advertisement Remove all ads
Advertisement Remove all ads
Share
Notifications

View all notifications


      Forgot password?
View in app×