Here is the class PersonType below just do Ques2 in C class
Here is the class PersonType below just do Ques2 in C++
class PersonType{
public:
void print() const;
void setName(string first, string last);
string getFirstName() const;
string getLastName() const;
PersonType(string first = \"\", string last = \"\");
private:
string firstName;
string lastName;
};
Solution
lass PersonType{
public:
void print()
{
cout<<\"Name is \"<<firstName<<lastName<<endl;
}
void setName(string first, string last)
{
strcpy(firstName,first);
strcpy(lastName,last);
}
string getFirstName()
{
return firstName;
}
string getLastName()
{
return lastName;
}
PersonType(string first = \"\", string last = \"\");
private:
string firstName;
string lastName;
};
class DocType:public PersonType
{
public:
void printSpec()
{
cout<<\"Doctor specialization is\"<<docSpec;
}
void setspec(string sp)
{
strcpy(docSpec,so);
}
private:
string docSpec;
};
class PatientType:public PersonType
{
public:
void printPatientInfo()
{
cout<<\" Patient I\'d is\"<<pid<<endl;
cout<<\"Age is \"<<age<<endl<<\" Date of birth is \"<<dob;
}
void setPatientInfo(string pd,int ag,string db)
{
strcpy(pid,pd);
age=ag;
strcpy(dob,db);
}
private:
string pid;
int age;
string dob;
};
class billType:public DocType,public PatientType
{
float bill;
public:
void setBill(float bl)
{
Bill=bl;
}
void printBill()
{
cout<< \" Bill is \"<<bill<<endl;
}
};
void main()
{
BillType b1.setName(\" Mathew\",\"John\");
b1.setPatientInfo(\"BO11\", 50,\"12-12-2015\");
b1.print();
b1.printPatientInfo();
b1.setspec(\"Cardio\");
b1.printSpec();
b1.setBill(40000.00);
b1.printBill();
}


