Question
Write the definition of a class PIC in C++ with the following description :
Private Members
– Pno //Data member for Picture Number (an integer)
– Category //Data member for Picture Category (a string)
– Location //Data member for Exhibition Location (a string)
– FixLocation //A member function to assign
//Exhibition Location as per category
//as shown in the following table| Category | Location |
| Classic | Amina |
| Modern | Jim Plaq |
| Antique | Ustad Khan |
Public Members
– Enter() //A function to allow user to enter values
//Pno, category and call FixLocation() function
– SeeAll() //A function to display all the data members
Solution
class PIC
{
int Pno;
char Category[20];
char Location[20];
void FixLocation();
public:
void Enter();
void SeeAll();
};
void PIC::FixLocation()
{
if(strcmpi(Category,'Classic')==0){
strcpy(Location,'Amina');
}
else if(strcmpi(Category,'Modern')==0){
strcpy(Location,'Jim Plaq');
}
else if (strcmpi(Category,'Antique')==0)
{
strcpy(Location,'Ustad Khan');
}
}
void PIC::Enter()
{
cin>>Pno;gets(Category);
FixLocation();
}
void PIC:: SeeAll()
{
cout<<Pno<<Category<<Location<<endl;
}



