Question: #include using namespace std; class painting { protected: string title; string author; int value; public: painting(string title = , string authour = ,
#include
using namespace std;
class painting {
protected:
string title;
string author;
int value;
public:
painting(string title = " ", string authour = " ", int value = 400);
void display();
};
painting::painting(string Title , string Author , int Value)
{
this->title = title;
this->author = author;
this->value = value;
}
void painting::display()
{
cout << "Title : " << title << author << value;
cout << endl;
}
class FamounsPainting :public painting {
public:
FamounsPainting(string title, string author, int value = 25000)
:painting(title, author, value)
{
}
};
int main()
{
//set N = 5 , record of 5 painting
int N = 5;
int M = 4; //no of famous painter
painting*paintings = new painting[N];
string famous[] = { "Degas","Monet","Picasso","Rembrandt" };
string title, author;
int i, k, j;
//loop for painting record
for (i = 0; i { cout << " Enter title of painting :"; cin>> title; cout << "Enter author of paintings:"; cin>>author; k = -1; for (j = 0; j { //compare with famous record string checkMe = author.substr(0, author.length() - 1); if (checkMe == famous[j]) { k = j; break; } } if (k != -1) paintings[i] = FamounsPainting(title, author); else paintings[i] = painting(title, author); } //print the details for (i = 0; i { paintings[i].display(); } system("pause"); return 0; } Still having a problem with the code can't seem to run on visual studio with a few errors with : cout << " Enter title of painting :"; cin>> title; cout << "Enter author of paintings:"; cin>>author; cout << "Title : " << title << author << value; cout << endl;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
