Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions