Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 2 In this assignment you are required to understand and manipulate dates using C++ through a predefined class. The main objectives are: 1) To

image text in transcribed

Exercise 2 In this assignment you are required to understand and manipulate dates using C++ through a predefined class. The main objectives are: 1) To compare the birthday dates of two different users identified by their names. 2) To display the following output: User 1: Marie Curie Birthday: 07 November 1867 User 2: Peter Curie Birthday: 15 May 1859 Marie is younger than Peter. Instructions The Date.h file in the ex2 folder of the zip file is a header file for a Date. You are required to implement this class in a Date.cpp file. You are also required to implement the main.cpp file. In the main.cpp file. You ask users their names and their birthdays. You need to create different Date objects and store their birthday in each object. The two constructors should initialise Date objects to ensure that they hold valid dates. In the Date.cpp file. You must implement one function overriding the operator . The operator should output the date using the format 02/11/2019, always using 2, 2 and 4 digits, with leading zeroes where necessary. The operator string function should return a string object Inot a C-string or character array) holding a string representation of the date using the format "Day Month Year", always using a "int string int" format, with leading zeroes where necessary. The comments in the header file indicate how string objects can be built by converting numbers to strings and using concatenation. (The to_string function is declared in the sstrings header file; it is not a member of any class.) This operator is invoked whenever a declaration of the form string s(d); is used when d is a Date object, and also if string(d) is used anywhere in an expression, so to test it you could use a statement such as cout stringlbdayl;; The three-argument constructor should output a warning message if any arguments are invalid, and the operator will of course produce output; none of the other functions must not perform any output.You must write a comparison operation function to check if the given date of the first user is either in the past or the future of that date. Meaning that if the second user birthday is in the past of the first user, the first user is younger than the second user, and vise versa. Note that the two comparison operators have lower precedence than so when testing them you will need to use code such as cout (d

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

Students also viewed these Databases questions