Question: Write a C++ program : (About Overloading Arithmetic Operators, Relational Operators, and Stream Extraction and Insertion Operators) In Public: complete the following statements - a)

Write a C++ program : (About Overloading Arithmetic Operators, Relational Operators, and Stream Extraction and Insertion Operators)

In Public: complete the following statements -

a) overload the + operator to add dates: make sure to overload + operator as a MEMBER function! IMPORTANT NOTES: 1) a day value cannot be bigger than 31: you can assume that all the months will have 31 days to simplify your coding! 2) a month value cannot be bigger than 12. b) overload the == operator to check if two dateType's are equal: make sure to overload == operator as a NON-MEMBER function! c) overload stream insertion operator << to print a dateType d) overload stream extraction operator >> to get a dateType from the keyboard

In int main(): complete the following statements -

e) add d1 and d2 using + operator and store the result in d3 f) print d1, d2, and d3 to the screen using stream insertion operator << g) enter day, month, year values from the keyboards to d3 using stream extraction operator >> h) print d3 to the screen using stream insertion operator << i) check equality of d1 and d2 using == operator and print a message to the user on the screen accordingly

____________Code that i have so far:

#include

using namespace std;

class dateType { private: int day; int month; int year; public: // constructor with default parameters dateType(int m= -1, int d= -1, int y= 1999);

//.................

};

dateType::dateType(int d, int m, int y) { month = m; day = d; year = y; }

int main() { dateType d1(4, 12, 2014); dateType d2(30, 1, 2014);

dateType d3;

//.................

system("pause"); return 0; }

_________________________

Thank you so much for the help.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!