icon

UseTopicwritingscode to get 5% OFF on your first order!

C++ coding

in C++
please see the attachments to check the main instruction for this assignment.

some q/a to help it from an instructor

Operator overloading Q/A

Q: This is from the lecture but I don’t really understand what’s going on here:
Date d4;
//later
d4 = d1;

A: Here we can do direct assignment if we overloaded the assignment operator for the Date

Q: Assignment or copy constructor?

A:

Date d1;

Date d2 = d1;//this is a copy constructor. The same as if I said:

Date d2(d1);

//this is assignment:

Date d1, d2;

////later

d1 = d2;

Q: “But what do I add? Days? Months? Years? There is some ambiguity here. Not to overload. “

Wouldn’t it do all of them?

A: If I have:

Date d;

……

d = d + 5;
Is it clear what do I add to that date d?

Q: Why is that istream and ostream?

A: in one case you enable the direct input to the Date, in other case you enable direct output. So you can:

Date d;

cin>>d; //to read in directly to the d.

cout<<d; //to print directly from the d.

You can leave a response, or trackback from your own site.

Leave a Reply

Powered by WordPress | Designed by: Premium WordPress Themes | Thanks to Themes Gallery, Bromoney and Wordpress Themes