(Solved):Use C++ in the following. Overload the + operator as indicated. Sample output for the given program: First vacation: Days: 7, People: 3 Second vacation: Days: 12, People: 3 include iostream usin… View Answer…

 

Question

Use C++ in the following.

Overload the + operator as indicated.

Sample output for the given program:

First vacation: Days: 7, People: 3

Second vacation: Days: 12, People: 3

 

include <iostream>

using namespace std;

class FamilyVacation{

public:

void SetNumDays(int dayCount);

void SetNumPeople(int peopleCount);

void Print() const;

FamilyVacation operator+(int moreDays);

private:

int numDays;

int numPeople;

};

void FamilyVacation::SetNumDays(int dayCount) {

numDays = dayCount;

return;

}

void FamilyVacation::SetNumPeople(int peopleCount) {

numPeople = peopleCount;

return;

}

 

EXPERT ANSWER

#include <iostream>
using namespace std;
class FamilyVacation{
public:
void SetNumDays(int dayCount);
void SetNumPeople(int peopleCount);
void Print() const;
FamilyVacation operator +(int moreDays);
private:
int numDays;
int numPeople;
};
void FamilyVacation::SetNumDays(int

Scroll to top