Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3. Complete the implementation of the copy constructor, destructor and operator=

ID: 3754310 • Letter: 3

Question

3. Complete the implementation of the copy constructor, destructor and operator= for the clas8 time24. Do not modify the main program. You must write the big three methods of the class so as to print messages to cout. Your program output must be the following (with possibly different addresses): conatructing: 18:34 stored at address 0x7fffSa?f1960 copying: 18:34 stored at address 0x7fffSa7f 1960 constructing: 00:00 stored at address 0x7fffSa7f1950 constructing: 05:08 stored at address 0x7fb4cb4000e0 The tine x i: 18:34 stored at address x7fff5a7f1960 The time y is: 18:34 stored at address 0x7fffsa7f1958 The time z i: 00:00 stored at address Ox7fff5a7f1950 The time p is: 05:08 stored at address 0x7fb4cb4000e0 assigning: 05:08 stored at address 0x7fb4cb4000eo assigning: 05:08 stored at address 0x7fff5a7f1960 The time z is: 05:08 stored at address 0x7fff5a7f1950 destroying: 05:08 stored at addresa 0x7fb4cb4000e0 destroying: 05:08 stored at address 0x7fffsa7f1950 destroying: 18:34 stored at address 0x7fffsa7f1958 destroying: 05:08 stored at addreas 0x7fff5a7f1960 /File: tine24big3.cpp the class time24 represents time on 24 hour clock times are written to a stream in the form hour:minute the big 3 methoda are implemented Programmer: your name Date: #include #include using nespace std class time24 private int hour int minute // hour betueen 0 and 23 // minute between 0 and 59 public time24(int h- 0, int 0); /* put big 3 prototypes here/ // constructor with default args

Explanation / Answer


Given below is the code for the question.
Please do rate the answer if it was helpful. Thank you

#include <iostream>
#include <fstream>
using namespace std;
class time24{
private:
int hour_;
int minute_;
public:
int hour(void) const;
int minute(void) const;
void hour(int h);
void minute(int m);
};
void write(ostream &out, const time24 &x);
time24 add(const time24 &x, const time24 &y);
int main()
{
time24 x, y, z;
x.hour(18);
x.minute(34);
y.hour(10);
y.minute(56);
cout << "The time x is: ";
write(cout, x);
cout << " The time y is: ";
write(cout, y);
z = add(x, y);
cout << " The sum of ";
write(cout, x);
cout << " and ";
write(cout, y);
cout << " is ";
write(cout , z);
cout << endl;
return 0;
}
//////////// Method of time24 ///////////////
int time24::hour(void) const{
return hour_;
}
int time24::minute(void) const{
return minute_;
}
void time24::hour(int h){
hour_ = h;
}
void time24::minute(int m){
minute_ = m;
}



/////////// time24 functions///////////////
void write(ostream &out, const time24 &x){
out << x.hour() / 10 << x.hour() % 10;
out << ":";
out << x.minute() / 10 << x.minute() % 10;
}
time24 add(const time24 &x, const time24 &y){
time24 z;
int h = x.hour() + y.hour();
int m = x.minute() + y.minute();
if(m >= 60){
m -= 60;
h++;
}
if(h >= 24)
h -= 24;
z.hour(h);
z.minute(m);
return z;
}

output
-----
The time x is: 18:34
The time y is: 10:56
The sum of 18:34 and 10:56 is 05:30

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote