Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

#include iostream> include using namespace std; class Book private string title

ID: 3721248 • Letter: #

Question

#include iostream> include using namespace std; class Book private string title public Book title-: Book(string) void setTitle(string) void showBook0: Book: Book(string inTitle) { title inTitle void Book::setTitle(string inTitle) { title inTitle 1. Complete the class by implementing the missing method showBook so that it outputs The book is titled "....The appropriate title goes here between themarks.." 2. Write a complete test main that will create an instance bookOne with a title "Cry The Beloved Country and then show your book. Thus the output of your main should be: The book is titled "Cry The Beloved Country"

Explanation / Answer

#include <iostream>

using namespace std;
class Book {
private:
string title;
public:
Book(){title="";};
Book(string);
void setTitle(string);
void showBook();
};
Book::Book(string inTitle) {
title=inTitle;
}
void Book::setTitle(string inTitle) {
title=inTitle;
}
void Book::showBook(){
cout<<"The book is titled "<<title<<endl;
}

int main()
{

Book bookOne("Cry The Beloved Country");
bookOne.showBook();

return 0;
}

Output: