Question: C++ I have some error messages I'm trying to clean up. There is a .h file and a .cpp file marked down below. I am

C++ I have some error messages I'm trying to clean up. There is a .h file and a .cpp file marked down below. I am getting no operator << and >> matches these operands and identifier getline is undefined. Here is my code.

BookClass.h

#include #include

using namespace std; class BookClass { string title; string author; string publisher; string isbn; double price; int year; int numInStock;

public: void storeBook(string bookTitle, string authorName, string bookPublisher, string bookISBN, double bookPrice, int bookYear, int booksInStock) { title = bookTitle; author = authorName; publisher = bookPublisher; isbn = bookISBN; price = bookPrice; year = bookYear; numInStock = booksInStock; } void displayBookInfo() { cout << "Title: " << title << endl; cout << "Author: " << author << endl; cout << "Publisher: " << publisher << endl; cout << "ISBN: " << isbn << endl; cout << "Price: " << fixed << setprecision(2) << price << endl; cout << "Year: " << year << endl; cout << "Books in Stock: " << numInStock << endl; } void checkOutBook() { if (numInStock > 0) { cout << "Checking out a book." << endl; numInStock--; } else cout << "No books in stock." << endl; } void returnBook() { cout << "Book returned successfully." << endl; numInStock++; } string getTitle() { return title; } int getNumInStock() { return numInStock; } };

Source Code

#include "BookClass.h"

void getBookInfo(BookClass &book) { string bookTitle, authorName, bookPublisher, bookISBN; double bookPrice; int bookYear, booksInStock; cout << "Enter book information"; cout << "Enter book title: "; getline(cin, bookTitle); cout << "Enter author name: "; getline(cin, authorName); cout << "Enter book publisher: "; getline(cin, bookPublisher); cout << "Enter book ISBN: "; cin >> bookISBN; cout << "Enter book price: "; cin >> bookPrice; cout << "Enter year published: "; cin >> bookYear; cout << "Enter the number of books in stock: "; cin >> booksInStock; book.storeBook(bookTitle, authorName, bookPublisher, bookISBN, bookPrice, bookYear, booksInStock); } int main() { BookClass book; getBookInfo(book); book.checkOutBook(); cout << book.getTitle() << " " << book.getNumInStock() << " remaining in stock." << endl; book.returnBook(); cout << book.getTitle() << " " << book.getNumInStock() << " remaining in stock." << endl;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!