rendered paste body#include<iostream>
#include<string>
using namespace std;
// Book Class
class Book{
protected:
string title;
string publicationYear;
string author;
public:
Book(const string title, const string pubYear, const string author);
void displayValues();
};
// Book Constructor
Book::Book(const string title, const string pubYear, const string author)
{
this->title = title;
this->publicationYear = pubYear;
this->author = author;
}
// displayValue function
void Book::displayValues()
{
cout<<"Title: "<<title<<" Year: "<<publicationYear<<" Author: "<<author<<endl;
}
// BookInventory Class
class BookInventory : public Book{
friend BookInventory operator+(BookInventory, int);
public:
BookInventory(const string title, const string pubYear, const string author, int totInv); // constructor
void displayValues(); // overloaded function
protected:
int totalInventory;
};
BookInventory::BookInventory(const string title, const string pubYear, const string author, int totInv) : Book(title, pubYear, author)
{
this->totalInventory = totInv;
}
void BookInventory::displayValues()
{
cout<<"Title: "<<title<<" Year: "<<publicationYear<<" Author: "<<author<< " Inventory: " << totalInventory << endl;
}
BookInventory operator+(BookInventory book, int invAdd) // this probably wont work....
{
int total;
total = book.totalInventory + invAdd;
}
int main()
{
BookInventory book1 = BookInventory("C++ Programming Guide", "2006", "Milton Jones",10);
book1.displayValues();
cout<<"Adding 10 to inventory."<<endl;
book1 = book1 + 10;
book1.displayValues();
cout<<"Subtracting 10 from inventory."<<endl;
//book1 = book1 - 10;
book1.displayValues();
system("pause");
return 0;
}