subject

Overload the + operator as indicated. Sample output for the given program: First vacation: Days: 7, People: 3
Second vacation: Days: 12, People: 3
#include
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;
}
// FIXME: Overload + operator so can write newVacation = oldVacation + 5,
// which adds 5 to numDays, while just copying numPeople.
/* Your solution goes here */
void FamilyVacation::Print() const {
cout << "Days: " << numDays << ", People: " << numPeople << endl;
return;
}
int main() {
FamilyVacation firstVacation;
FamilyVacation secondVacation;
cout << "First vacation: ";
firstVacation. SetNumDays(7);
firstVacation. SetNumPeople(3);
firstVacation. Print();
cout << "Second vacation: ";
secondVacation = firstVacation + 5;
secondVacation. Print();
return 0;
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 20:00
When you mouse over and click to add a search term this(these) boolean operator(s) is(are) not implied. (select all that apply)?
Answers: 1
question
Computers and Technology, 22.06.2019 23:30
For her science class, elaine is creating a presentation on weather in the united states. she wants to make the presentation beautiful and interesting by drawing simple cloud or wave shapes. which is the best way for elaine to draw these shapes?
Answers: 1
question
Computers and Technology, 25.06.2019 04:30
If you have watched pretty little liars(pll)what are the names of the main characters? all of them and the boyfriends and girlfriends too.
Answers: 2
question
Computers and Technology, 25.06.2019 08:00
Ais the hardware where the data is actually stored.
Answers: 1
You know the right answer?
Overload the + operator as indicated. Sample output for the given program: First vacation: Days: 7,...
Questions
question
Mathematics, 02.08.2019 21:00
Questions on the website: 13722363