Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab Exercise - Overloading Part 1 Change the sameDay function into a overloaded = = operator. This will be a member function as demonstrated in

Lab Exercise - Overloading
Part 1
Change the sameDay function into a overloaded == operator. This will be a member function as demonstrated in the notes. Remember that you will want to compare the month, day, and year.
Add an overloaded ++ operator (as a member function, shown in the notes)
Just for fun, change the printDate function into an overloaded operator as a non-member. The prototype in the .h will look like this:
ostreams operator(ostreamb, const Dates);
The function itself will look like this:
Ostreams operator(ostreams os, const Dates myDate)
os "Date 1s: " myDate. getMonth()
=l'' myDate.getDay ()
??=" myDate. getYear() endl;
return os;
Explain why operator must be overloaded as a non-member.
Part 2
Overload the + operator so that the following lines of code run in main:
More Details:
Define two functions. The prototypes will look like this:
Date operatort (const Dates, int);
Date operatort (int, const Dates);
Are they member or non-member functions? (Notice how many arguments they have)
Both functions will create a temporary date and return it.
Think about reusing as much code as possible.
a. For one implementation of operatort, can you call the operator+t function?
b. For the second implementation of operatort, can you call the first operator + function?
c. Together these two functions should be no more that 10 lines of code in the bodies. If you make it longer, you are working too hard.
Which of the two functions must be defined as a non-member? Why?
Sample Run (after Part 2)
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

26. What is a wholesale motor vehicle loan? (LG 14-8)

Answered: 1 week ago

Question

Which helping behaviors do I want to improve the most?

Answered: 1 week ago