Classes and objects

Source: Internet
Author: User

1 //A class (the commonality and characteristics of a batch of objects) is an abstraction of an object, and an object is a concrete instance of the class2 //Structure types and struct variables can be used to understand the same struct type can define multiple structural body variables3 //C + + also declares a class type first and then uses struct type to define class variables4 //classes are abstract and do not consume memory, but objects are specific, occupy storage space,5 //with the language Foundation to understand another language is a kind of enjoyment, can understand a lot of new things.6#include <iostream>7 using namespacestd;8 class Time9 {Ten  Public: One     voidset_time (); A     voidshow_time (); - Private: -     inthour; the     intminute; -     intsec; - }; - intMain () + { - Time T1; + t1.set_time (); A t1.show_time (); at Time T2; - t2.set_time (); - t2.show_time (); -     return 0; - } - voidtime::set_time () in { -Cin>>hour>>minute>>sec; to } + voidtime::show_time () - { thecout<":"<<minute<<":"<<sec<<Endl; *}

Classes and objects

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: 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.