12th Week on Machine practice Project 3--Date Time class

Source: Internet
Author: User

Define a date class date with data members including year, month, day, setdate (int y,int m,int D), and printdate () functions for setting date and display dates, and then defining a time class, where data members include time, minutes, seconds, SetTime ( The int h,int m,int s) and the Printtime () function are used to set the time and display time respectively, on the basis of which we define a date-time class timedate, make full use of the methods provided in the existing two classes, and implement the setting and display of the date and time. Please implement Class timedate.


Code

#include <iostream> using namespace std;
    Class Time {Private:int hour;
    int minute;
int sec;
    Public:time (int h=0,int m=0,int s=0): Hour (h), Minute (m), SEC (s) {} void settime (int h,int m,int s);
void Printtime ();
};
    void time::settime (int h,int m,int s) {hour=h;
    Minute=m;
Sec=s;
} void Time::P rinttime () {cout< 

Run Result:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.