Question: Subject: C++ I am creating a class called Book located in a file called Book.h: #ifndef Book_H #define Book_H #include using namespace std; class Book
Subject: C++
I am creating a class called Book located in a file called Book.h:
#ifndef Book_H #define Book_H #include
}; #endif
I also created another header called Author.h located here:
#ifndef Author_H #define Author_H #include
#endif
I need to create two files; one called Book.cpp that defines the functions and one called MainBook.cpp that has a main() function in it.
Heres what I have so far in Book.cpp:
ook::Book(string name, Author::Author, double price, int qtyInStock) {
}
string Book::getName() { return name; }
string Book::getAuthor() { return author; }
double Book::getPrice() { return price; }
void Book::setPrice(double price) { double price = 0; }
int Book::getQtyInStock() { return 0; }
void Book::setQtyInStock(int qtyInStock) { }
void Book::print() { cout << name << " by " << Author::author << " " << Author::gender << " @ " << Author::email << endl; }
string Book::getAuthorName() { return string(); }
Here is what is needed:
Assume that a book is written by one and only one author.
print() function prints "'book-name' by author-name (gender) @ email".
getAuthorName() returns the name of the author of this Book instance.
Inside the main function:
- Declare and construct an instance of Author
- Declare and construct an instance of Book
- Call the print function of the Book
- Call the getAuthorName function of the Book
I would appreciate some help!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
