Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

Compare the current team to the ideal team.

Answered: 1 week ago

Question

a. Do team members trust each other?

Answered: 1 week ago

Question

How do members envision the ideal team?

Answered: 1 week ago