Given main(), complete the Artist class (in files Artist.h and Artist.cpp) with constructors to initialize an artist's information, get member functions, and a PrintInfo() member function. The default constructor should initialize the artist's name to "None" and the years of birth and death to 0. PrintInfo() should display Artist Name, born XXXX if the year of death is -1 or Artist Name (XXXX-YYYY) otherwise. Complete the Artwork class (in files Artwork.h and Artwork.cpp) with constructors to initialize an artwork's information, get member functions, and a PrintInfo() member function. The constructor should by default initialize the title to "None", the year created to 0. Declare a private field of type Artist in the Artwork class. Ex. If the input is: Pablo Picasso 1881 1973 Three Musicians 1921 the output is: Artist: Pablo Picasso (1881-1973) Title: Three Musicians, 1921 If the input is: Brice Marden 1938 -1 Distant Muses 2000 the output is: Artist: Brice Marden, born 1938 Title: Distant Muse
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
7.25 LAB: Artwork label (classes/constructors)
Given main(), complete the Artist class (in files Artist.h and Artist.cpp) with constructors to initialize an artist's information, get member functions, and a PrintInfo() member function. The default constructor should initialize the artist's name to "None" and the years of birth and death to 0. PrintInfo() should display Artist Name, born XXXX if the year of death is -1 or Artist Name (XXXX-YYYY) otherwise.
Complete the Artwork class (in files Artwork.h and Artwork.cpp) with constructors to initialize an artwork's information, get member functions, and a PrintInfo() member function. The constructor should by default initialize the title to "None", the year created to 0. Declare a private field of type Artist in the Artwork class.
Ex. If the input is:
Pablo Picasso 1881 1973 Three Musicians 1921the output is:
Artist: Pablo Picasso (1881-1973) Title: Three Musicians, 1921If the input is:
Brice Marden 1938 -1 Distant Muses 2000the output is:
Artist: Brice Marden, born 1938 Title: Distant Muses, 2000![LAB
7.25.1: LAB: Artwork label (classes/constructors)
0/ 10
АCTIVITY
File is marked as read only
Current file main.cpp
main.cpp
1 #include "Artist.h"
2 #include "Artwork.h"
3 #include <iostream>
4 #include <string>
5 using namespace std;
Artist.h
6.
Artist.cpp
7 int main(int argc, const char* argv[]) {
8
string userTitle, userArtistName;
int yearCreated, userBirthYear, userDeathYear;
Artwork.h
9.
10
Artwork.cpp
getline(cin, userArtistName);
cin >> userBirthYear;
cin.ignore();
cin >> userDeathYear;
cin.ignore();
getline(cin, userTitle);
cin >> yearCreated;
cin.ignore();
11
12
13
14
15
16
17
18
19
20
Artist userArtist =
Artist(userArtistName, userBirthYear, userDeathYear);
21
22
Artwork newArtwork = Artwork(userTitle, yearCreated, userArtist);
23
24
newArtwork.PrintInfo();
25 }](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F04d72593-097f-4b69-938e-8eb3398dcc08%2Fd78e5f2f-8018-4c1d-a78b-727e9c539cbe%2Fxmwc1uh_processed.png&w=3840&q=75)


Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 8 images









