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); }; It asks to create 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. 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 don't 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

1) 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);

};

It asks to create 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.

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 don't need to demonstrate calling these operators.

 

 

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Data members
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
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning