Consider the following class Date, which represents a date using three ints for month, day and year: class Date { private:  int month;  int day; int year; public:  Date() { month = day = year = 0; }  Date(int m, int d, int y) { month = m; day = d; year = y; }  bool operator==(Date);  bool operator<(Date); };   Write an implementation for both overloaded operators.  == should return true if the Date objects are equivalent and false if not.  < should return true if the Date of the calling object (left object) comes before the parameter Date object (right object) and false if not.   You may assume that all objects of class Date are valid, i.e. month is between 1 and 12, inclusive; day contains an appropriate day for the given month, and year can be anything.   You do not need to demonstrate calling these operators.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter11: Inheritance And Composition
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question

Consider the following class Date, which represents a date using three ints for month, day and year:

class Date

{

private:

 int month;

 int day;

int year;

public:

 Date() { month = day = year = 0; }

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

 bool operator==(Date);

 bool operator<(Date);

};

 

Write an implementation for both overloaded operators.  == should return true if the Date objects are equivalent and false if not.  < should return true if the Date of the calling object (left object) comes before the parameter Date object (right object) and false if not.

 

You may assume that all objects of class Date are valid, i.e. month is between 1 and 12, inclusive; day contains an appropriate day for the given month, and year can be anything.

 

You do not need to demonstrate calling these operators.

 

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage