16) Write a C++ program to declare a class "Book" containing data members book_name, auther name, and price .Accept this information for one object of the class using pointer to that object.

Anonymous School

            (Minds of Hacker)

--------------------------------


 Write a C++ program to declare a class "Book" containing data members book_name, auther name, and price .Accept this information for one object of the class using pointer to that object.


C++ Practical



#include <iostream>
using namespace std;
class book
{
public:
    char book_name[20], author_name[20];
    int price;
    void get()
    {
        cout << "Enter the Book name, author name, price respectivaly\n";
        cin >> book_name >> author_name >> price;
    }
    void display()
    {
        cout << "Data Enter by you\n"
             << "\nBook Name ="
             << book_name << "\nAuthor name= " << author_name << "\nPrice = "
             << price
             << "\n";
    }
};
int main()
{
    book a, *b;
    b = &a;
    b->get();
    b->display();
}


Output:



Enter the Book name, author name, price respectivaly C++ abcd 255 Data Enter by you Book Name =C++ Author name= abcd Price = 255




 *******************Don't Make Learning Hard*****************



Follow us on :-

1) YouTube Channel :- Click Here

2) Blog                     :- Click Here


NextGen Digital... Welcome to WhatsApp chat
Howdy! How can we help you today?
Type here...