1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
yarga [219]
3 years ago
4

Use C++ in the following.

Computers and Technology
1 answer:
Neporo4naja [7]3 years ago
6 0

Answer:

See explaination for program code

Explanation:

/* C++ Program that implements the + operator overloading */

#include <iostream>

using namespace std;

//Class definition

class FamilyVacation

{

public:

void SetNumDays(int dayCount);

void SetNumPeople(int peopleCount);

void Print() const;

FamilyVacation operator+(int moreDays);

private:

int numDays;

int numPeople;

};

//Class implementation

//Function that sets number of days

void FamilyVacation::SetNumDays(int dayCount)

{

numDays = dayCount;

}

//Function that sets number of people

void FamilyVacation::SetNumPeople(int peopleCount)

{

numPeople = peopleCount;

}

//Function that prints number of days and number of people

void FamilyVacation::Print() const

{

cout << " Days: " << numDays << ", People: " << numPeople;

}

//Overloading plus operator

FamilyVacation FamilyVacation::operator+(int moreDays)

{

//Adding moreDays to existing days

numDays = numDays + moreDays;

//Returning current object

return *this;

}

//Main function

void main()

{

//Creating first vacation object

FamilyVacation vacation1;

//Setting number of days to 7 of object vacation1

vacation1.SetNumDays(7);

//Setting number of people to 3 of object vacation1

vacation1.SetNumPeople(3);

//Printing vacation 1 object values

cout<<"\n First Vacation: ";

vacation1.Print();

//Adding extra 5 days to object vacation1

FamilyVacation vacation2 = vacation1 + 5;

//Printing vacation 2 object values

cout<<"\n Second Vacation: ";

vacation2.Print();

cout<<"\n\n";

}

kindly check attachment for output

You might be interested in
To save the changes to the layout of a table, click the Save button on the _____.
kari74 [83]
Quick access toolbar :)))))))))
7 0
3 years ago
Consider the cement used for the foundation; the bricks and timber used for the walls; and the shingles used for the roof. All o
gavmur [86]
<span>Consider the cement used for the foundation; the bricks and timber used for the walls; and the shingles used for the roof. All of these are __________ in making the house.

A. Elements</span>
6 0
3 years ago
What may happen if a large number of computer users are attempting to access a web site at the same time that you are?
Andrews [41]
D (you may be unable to link to the site). The site cannot handle the large load of requests and are queued therefore, the response will be slowed down immensely. <span> </span>
5 0
4 years ago
The letters a, e, i, o and u are the only vowels. Write a function named vowelUseDict() takes a string t as a parameter and comp
Andru [333]

Please specify the programming language.


3 0
4 years ago
Cyber security class i need help​
makkiz [27]

Answer:

Explanation:

yooooo it b

5 0
3 years ago
Other questions:
  • The actual database of active directory shared resources is stored on one or more computers designated as:
    10·1 answer
  • I just started game development using unity, I’m trying to control my sphere moving on a flat surface using the W,A,S,D keys, if
    5·1 answer
  • Web 2.0 has led to a shift just from consuming content towards what
    6·1 answer
  • Help me match these answers
    5·1 answer
  • "Consideration of being digitally" literate Means to produce digital technology Participate in digital activities none of the ch
    11·1 answer
  • HELP 11 pointsw to the person who helps me
    11·2 answers
  • Question 8 A data analyst is working with a data frame named stores. It has separate columns for city (city) and state (state).
    12·1 answer
  • As you are discussing marketing with a client, you try to explain how individuals find sites. Which tool will you explain as the
    8·1 answer
  • Write A Code In Python
    8·2 answers
  • The technologist has recorded the red cell morphology as macrocytic. which mcv value would confirm this observation?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!