Answer to Question #222503 in C++ for Jaguar

Question #222503
Consider the class definition below and answer the questions that follow:

class InsurancePolicy
{
public:
InsurancePolicy();
InsurancePolicy(int pNr, string pHolder, double aRate);
~InsurancePolicy();
void setPolicy(int pNr, string pHolder, double aRate);
int get_pNr()const;
string get_pHolder()const;
double get_aRate()const;
private:
int policyNr;
string policyHolder;
double annualRate;
};

(d) Add a member function
void showPolicy(ostream & out)const;
to the class InsurancePolicy as well as to the class CarInsurance in order
to display the member variables of InsurancePolicy and CarInsurance.
1
Expert's answer
2021-08-06T15:32:26-0400
#include <iostream>
#include <string>
using namespace std;

class InsurancePolicy{
public:
	InsurancePolicy();
	InsurancePolicy(int pNr, string pHolder, double aRate);
	~InsurancePolicy();
	void setPolicy(int pNr, string pHolder, double aRate);
	int get_pNr()const;
	string get_pHolder()const;
	double get_aRate()const;
	void showPolicy(ostream & out)const;
private:
	int policyNr;
	string policyHolder;
	double annualRate;
};


void InsurancePolicy::showPolicy(ostream & out)const{
	out<<"Policy Nr: "<<policyNr<<endl;
	out<<"Policy Holder: "<<policyHolder<<endl;
	out<<"Annual Rate: "<<annualRate<<endl;
}






class CarInsurance: public InsurancePolicy{
private:
	string excess;
public:
	void set_excess(string ex);
	string get_excess();
	void showPolicy(ostream & out)const;
};


void CarInsurance::showPolicy(ostream & out)const{
	InsurancePolicy::showPolicy(out);
	out<<"Excess: "<<excess<<endl;
}


int main(){




	
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS