Question
The Book class has a default constructor with no parameters. Define an overloaded constructor that takes two string parameters and initializes the book's title and
The Book class has a default constructor with no parameters. Define an overloaded constructor that takes two string parameters and initializes the book's title and author with the strings.
Ex: If the input is Painting West, then the output is:
Book: Unknown, NoName Book: Painting, West
#include
class Book { public: Book(); Book(string bookTitle, string bookAuthor); void Print(); private: string title; string author; };
Book::Book() { title = "Unknown"; author = "NoName"; }
/* Your code goes here */
void Book::Print() { cout << "Book: " << title << ", " << author << endl; }
int main() { string bookTitle; string bookAuthor; cin >> bookTitle; cin >> bookAuthor; Book emptyBook; Book book1(bookTitle, bookAuthor); emptyBook.Print(); book1.Print();
return 0; }
c++ and please please make it correct
whats blurr about it, its written out
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started