Sdut Object-Oriented Programming Practice 5 (simple class and object)

Source: Internet
Author: User

Object-Oriented Programming machine practice 5 (class and object) Time Limit: 1000 ms memory limit: 65536 K The topic description defines the class time. The time has three common data members, hour, Min, and SEC, which respectively indicate hours, minutes, and seconds.
Define the time Class Object T1 in the main function, input the data members of T1 in the main function, and then output the data members. Enter the three data members hour, Min, and SEC of the input class object. Output three data members hour, Min, and SEC of the output class object. Sample Input
 
9 10 11
Sample output
 
9:10:11
# Include <iostream> using namespace STD; // declare class type class time {// define private part private: int h; int m; int s; // define public part public: void settime () // value assignment member function {CIN> H> m> S;} void Showtime () // output member function {cout <H <": "<m <": "<S <Endl ;}; // do not forget this semicolon // main function int main () {class time t; t. settime (); T. showtime (); Return 0 ;}


Sdut Object-Oriented Programming Practice 5 (simple class and object)

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.