Write a C++ program Design, design and implement a date class
Design and implement a date class MyDate (1)
(1) Provide a conversion constructor to convert an integer into a date, the rule is that the integer represents from 1970-01-01 00:00:
The number of seconds since 00 UTC.
(2) Provide a constructor that accepts three integers representing the three fields of year, month, and day.
(3) Provide a member function bool equals(const MyDate&) const, which
returns , otherwise returns false. Provides a member function bool lessThan(const MyDate&) const,
which returns true when the date of this object is earlier than the date of the parameter, otherwise returns false. Similarly, provide the following
member functions:
bool lessThanOrEquals(const MyDate&) const
bool greaterThan(const MyDate&) const
bool greaterThanOrEquals(const MyDate&) const
(4) Provide the member function MyDate add(int) const, which means returning this object to increase the corresponding Days of the date.
Similarly, the following member function MyDate subtract(int) const is provided.
(5) Provide the member function int subtract(MyDate) const, the return value is the distance between this object and the formal parameter,
when the object is later than the formal parameter, it returns a positive integer.
(6) Provide member function string toString() const, the output conforms to ISO8601 standard.
Requirements for writing homework:
A header file MyDate.h is attached with this article. The homework needs to complete a MyDate.cpp and implement this class. For the content in this
file, only private member variables and member functions can be added, and no other content can be added, nor
can the existing content be modified. Pay attention to the upper and lower case of the file name and write it strictly according to the requirements. The test sample of this job is in main.cpp
, and the test range is 1900-01-01 ~ 2099-12-31.
Assignment scoring method:
Students submit two files, MyDate.h and MyDate.cpp. The teacher's test method is to put MyDate.h, MyDate.cpp,
and main.cpp (provided separately, different from the use case given in the assignment) in a directory. Use g++ to compile and link:
g++ -std=c++11 *.cpp # Compile and link. -std=c++11 is to use the C++11 standard
and then judge the score according to the running result.
http://www.6daixie.com/contents/13/1314.html
The core members of the team mainly include Silicon Valley engineers, BAT front-line engineers, top 5 master and doctoral students in China, and are proficient in German and English! Our main business scope is to do programming assignments, course design and so on.
Our field of direction: window programming, numerical algorithm, AI, artificial intelligence, financial statistics, econometric analysis, big data, network programming, WEB programming, communication programming, game programming, multimedia linux, plug-in programming program, API, image processing, embedded/MCU database programming, console process and thread, network security, assembly language hardware Programming software design engineering standards and regulations. The ghostwriting and ghostwriting programming languages or tools include but are not limited to the following:
C/C++/C# ghostwriting
Java ghostwriting
IT ghostwriting
Python ghostwriting
Tutored programming assignments
Matlab ghostwriting
Haskell ghostwriting
Processing ghostwriting
Building a Linux environment
Rust ghostwriting
Data Structure Assginment
MIPS ghostwriting
Machine Learning homework ghostwriting
Oracle/SQL/PostgreSQL/Pig database ghostwriting/doing/coaching
web development, website development, website work
ASP.NET website development
Finance Insurance Statistics Statistics, Regression, Iteration
Prolog ghostwriting
Computer Computational method
Because professional, so trustworthy. If necessary, please add QQ: 99515681 or email: [email protected]
WeChat: codinghelp