Question: Define a default constructor that initializes the data members, string author, string title, and integer year, with the default values Undefined, Incomplete, and -1, respectively.

Define a default constructor that initializes the data members, string author, string title, and integer year, with the default values "Undefined", "Incomplete", and -1, respectively.

Ex: If the input is Lara Azalea 1991, then the output is:

Author: Undefined, Title: Incomplete, Year: -1 Author: Lara, Title: Azalea, Year: 1991

#include #include using namespace std;

class Essay { public: Essay(); void SetAuthor(string essayAuthor); void SetTitle(string essayTitle); void SetYear(int essayYear); void Print();

private: string author; string title; int year; };

/* Your code goes here */

void Essay::SetAuthor(string essayAuthor) { author = essayAuthor; }

void Essay::SetTitle(string essayTitle) { title = essayTitle; }

void Essay::SetYear(int essayYear) { year = essayYear; }

void Essay::Print() { cout << "Author: " << author << ", Title: " << title << ", Year: " << year << endl; }

int main() { string newAuthor; string newTitle; int newYear; Essay essay1;

essay1.Print(); cin >> newAuthor; cin >> newTitle; cin >> newYear;

essay1.SetAuthor(newAuthor); essay1.SetTitle(newTitle); essay1.SetYear(newYear);

essay1.Print();

return 0; }

c++ and please please make it corre

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!