Question: Can you see what is wrong with this code an fix it for me please! Here are all the files: main.cpp #include Artist.h #include Artwork.h

Can you see what is wrong with this code an fix it for me please!

Here are all the files:

main.cpp

#include "Artist.h" #include "Artwork.h" #include #include using namespace std;

int main() { char userTitle[101], userArtistName[101]; int yearCreated, userBirthYear, userDeathYear;

cin.getline(userArtistName, 101); cin >> userBirthYear; cin.ignore(); cin >> userDeathYear; cin.ignore(); cin.getline(userTitle, 101); cin >> yearCreated; cin.ignore();

Artist userArtist = Artist(userArtistName, userBirthYear, userDeathYear);

Artwork newArtwork = Artwork(userTitle, yearCreated, userArtist);

newArtwork.PrintInfo(); }

Artist.h

#ifndef ARTISTH #define ARTISTH

#include using namespace std;

class Artist{ public: Artist();

Artist(char *artistName, int birthYear, int deathYear);

void GetName(char *returnName) const;

int GetBirthYear() const;

int GetDeathYear() const;

void PrintInfo() const; private: char name[100]; int birthYear; int deathYear;

};

#endif

Artist.cpp

#include "Artist.h" #include #include using namespace std;

// TODO: Define default constructor Artist::Artist() { strcpy(name, "unknown"); birthYear = -1; deathYear = -1; } // TODO: Define second constructor to initialize // private fields (artistName, birthYear, deathYear) // TODO: Define get functions: GetName(), GetBirthYear(), GetDeathYear() Artist::Artist(const char* name, int birthYear, int deathYear){ strcpy(this->name, name); this->birthYear = birthYear; this->deathYear = deathYear; } const char* Artist::GetName() const{ return name; }

int Artist::GetBirthYear() const{ return birthYear; }

int Artist::GetDeathYear() const{ return deathYear; }

// TODO: Define PrintInfo() function // If deathYear is entered as -1, only print birthYear void Artist::PrintInfo() const { cout

if (birthYear >= 0 && deathYear >= 0) { cout = 0 && deathYear

cout

Artwork.h

#ifndef ARTWORKH #define ARTWORKH

#include "Artist.h"

class Artwork{ public: Artwork();

Artwork(char *newTitle, int newYearCreated, Artist newArtist); void GetTitle(char *returnTitle);

int GetYearCreated();

void PrintInfo(); private: // TODO: Declare private data members - title, yearCreated char title[100]; int yearCreated; // TODO: Declare private data member artist of type Artist Artist artist; };

#endif

Artwork.cpp

#include #include #include "Artwork.h"

using namespace std;

// TODO: Define default constructor Artwork::Artwork(){ strcpy(title, "unknown"); yearCreated = -1; artist = Artist(); } // TODO: Define second constructor to initialize // private fields (title, yearCreated, artist) // TODO: Define get functions: GetTitle(), GetYearCreated() Artwork::Artwork(const char* title, int yearCreated, const Artist& artist){ strcpy(this->title, title); this->yearCreated = yearCreated; this->artist = artist; } const char* Artwork::GetTitle() const{ return title; }

int Artwork::GetYearCreated() const{ return yearCreated; }

const Artist& Artwork::GetArtist() const{ return artist; }

// TODO: Define PrintInfo() function // Call the PrintInfo() function in the Artist class to print an artist's information void Artwork::PrintInfo() const{ artist.PrintInfo(); cout

Ex: If the input is:

Pablo Picasso 1881 1973 Three Musicians 1921 

the output is:

Artist: Pablo Picasso (1881 to 1973) Title: Three Musicians, 1921

Here is the error!

Can you see what is wrong with this code an fix it

for me please! Here are all the files: main.cpp #include "Artist.h" #include

Artwork. cpp:8:1: note: 'Artwork: Artwork()' B I Artwork: :Artwork } \{ In file included from Artwork. cpp:3: Artwork.h:6:7: note: 'class Artwork' defined here 6 I class Artwork Artwork.cpp:21:13: error: no declaration matches 'const char* Artwork: GetTitle() const' 21 I const char* Artwork: Gettitle() const \{ In file included from Artwork. cpp:3: Artwork.h:11:12: note: candidate is: 'void Artwork: GetTitle (char*)' 11 I void Getitle (char returnTitle); Artwork.h:6:7: note: 'class Artwork' defined here 6 I class Artwork Artwork.cpp:25:5: error: no declaration matches 'int Artwork: Getyearcreated() const' 25 I int Artwork: GetYearcreated() const \{ In file included from. Artwork. cpp: 3: Artwork.h:13:11: note: candidate is: 'int Artwork: GetYearcreated()' 13 I int GetYearcreated(); nrtwork.h:6:7: note: 'class Rrtwork' defined here 6 I class Artwork Artwork. cpp:29:15: error: no declaration matches 'const Artists Artwork: CetArtist() const' 29 I const Artists nrtwork: Gethrtist() const f I Artwork.cpp:29:15: note: no functions named 'const Artists Artwork: :GetArtist () const' In file included from. Artwork. cpp: 3 : Artwork.h:6:7: note: 'class Artwork' defined here 6 I class Artwork\{ Artwork. cpp:35:6: error: no declaration matches 'void Artwork: Frintinfo } const' 35 I void Artwork: Printinfo() const( In file included from Artwork. cpp:3: Artwork.h:15:12: note: candidate is: 'void Artwork::Printinfo()' 151 void printinfo(); Artwork.h:6:7: note: 'class Artwork' defined here 6 I class nrtworkf

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!