Question
Write the definition of a class Photo In C++ with the following description:
Private Members
- Pno //Data member for Photo Number (an integer)
-Category //Data.member for Photo Category (a string)
- Exhibit I // Data member for Exhibition Gallery (a string)
- FixExhibit //A member function to assign Exhibition Gallery as per Category as shown in the following table
Category | Exhibit |
Antique | Zaveri |
Modern | Johnsen |
Classic | Terenida |
Public Members
-Register() //A function to allow user to enter values Pno I category and call FixExhibi t () function
- ViewAll() //A function to display all the data members
Solution
class Photo
{
int Pno;
char Category[20];
char Exhibit[20];
void FixExhibit();
public:
void Register();
void ViewAll();
};
void Photo::FixExhibit()
{
if(strcmpi(Category, "Antique")==0)
strcpy(Exhibit, "Zaveri");
else if(strcmpi(Category, "Modern")==0)
strcpy(Exhibit,”Johnsen”);
else if strcmpi(Category, "Classic")==0)
strcpy(Exhibit,”Terenida”);
}
void Photo::Register()
{
cin>>Pno;
gets(Category);
FixExhibit();
}
void Photo:: ViewAll()
{
cout<<Pno<<Category<<Exhibit<<endl;
}
Is there an error in this question or solution?
Solution Write the Definition of a Class Photo in C++ with the Following Description: Private Members Pno Category Exhibit I Public Members Register() Viewall() Concept: Member of a Class - Data Members and Member Functions (Methods).