Program is to define a class as library, C/C++ Programming

Program is to define a class as library:

Program is to define a class as library and perform all the function of library management by using classes and object

class library

  {

  private:

    int bkno;

    char bkname[20],auth[20],pub[20];

    float price;

    int copies;

    int issues;

  public:

    library() // constructor that is assigning initial values

     {

     copies=10;

     price=150.50;

     }

    void input();

    void issue();

    void rtbook();

    void disp();

   };

 

 void library :: input()

   {

   clrscr();

   cout<<" enter the book number "<<"\n";

   cin>>bkno;

   cout<<" enter the book name"<<"\n";

   gets(bkname);

   cout<<" enter the author name "<<"\n";

   gets(auth);

   cout<<" enter the publisher name "<<"\n";

   gets(pub);

   cout<<" enter the no. of copies you want to issue ";

   cin>>issues;

   }

  void library::issue()

    {

    if (issues>copies)

      {

      cout<<" The book is not available ";

      exit(0);

      }

    else

      cout<<" The book is available "<<"\n";

    }

 

  void library::rtbook()

    {

    clrscr();

    int bookr;

    cout<<" enter the book number ";

    cin>>bookr;

     if (bookr==bkno)

       {

       cout<<" the book has been returned ";

       }

     else

       cout<<" the book no. you have entered is wrong ";

     }

 

 void main()

  {

  library book;

  book.input();

  book.issue();

  book.rtbook();

  book.disp();

  }

 

Posted Date: 10/19/2012 5:28:03 AM | Location : United States







Related Discussions:- Program is to define a class as library, Assignment Help, Ask Question on Program is to define a class as library, Get Answer, Expert's Help, Program is to define a class as library Discussions

Write discussion on Program is to define a class as library
Your posts are moderated
Related Questions
how to use nested loop of for in array

Question 1) What are the commonly used input/output functions in C? Question 2) What is the difference between function declaration and function definition? Write a recursive

what is the difference between call by reference and call by pointer method?

A: In C++, the definition of NULL is 0, thus there is only an aesthetic difference. I prefer to ignore macros, so I employ 0. Another difficulty with NULL is that people sometimes

can we use const data member in static. member function with example.

What is the difference among const char *myPointer and char *const myPointer?  A: Const char *myPointer is a non constant pointer to constant data; whereas char *const myPointer

Problem Implement a class called employee that contains name, employee number and department code. Include a member function getdata() to get data from user and store it in the

Determine the types of Container class Container class can be of 2 types: - Heterogeneous container - Here container class comprise a group of mixed objects - Homogeneou

Rahul is a newbie to the programming and while learning the programming language he came to know the following rules: · Each program must start with ''{'' and end with '

Mixed Mode Expressions and Implicit type Conversions A mixed mode expression is one in which the operands are not of the similar type. In this case, the operands are converted