(a) Define the class
Book
with all the basic attributes such as title, author, publisher, price, etc. Define the default constructor, member functionsdisplay_data()
for displaying theBook
details. Use appropriate access control specifiers in this program.
Output:
Line 16: error: stray '\342' in program
compilation terminated due to -Wfatal-errors.
Source:
#include <iostream>
#include <string>
using namespace std;
Class Book
{
Int ISBNNo;
Char Title[30];
Char Author[30];
Char pub[50];
Float price;
Public: Book()
{
ISBNNO = 1001;
Strcpy(Title, ”C++ Programming”);
Strcpy(Author, “E.Balagurusamy”);
Strcpy(pub, “Tata Press”);
Price = 300;
}
Void display_data()
{
Cout << ”Book ISBNNO” << ISBNNO << endl;
Cout << ”Book Title” << Title << endl;
Cout << ”Book Author Name” << Author << endl;
Cout << ”Book Publisher” << pub << endl;
Cout << ”Book Price” << price << endl;
}
};
Main()
{
Book B;
B.display_data();
getch();
}