Use of C ++ program practices

Source: Internet
Author: User

When I first learned the code in the C ++ practice class, it was easy to understand the class. The interface is also unfriendly (it is estimated that no one except me can understand what it is ).

/* Design a people class for personnel management. Considering universality, only attributes of all types of personnel are abstracted: Number, sex, birthday, ID, and so on. The "birthdate" is defined as an embedded sub-object of the "date" class. Use member functions to record and display personnel information. Requirements include constructor and destructor, copy constructor, inline member function, and aggregation. Defines a date class, including year, month, and day. In the defined people class, including number, sex, birthday, and ID ). The main () function constructs several people class objects and provides several member functions to input and display personnel information. In addition, each class requires constructors and destructor. Program name: lab2_3.cpp. */# Include <iostream> using namespace STD; Class Date {PRIVATE: int year; int month; int day; public: Date () {cout <"date is created" <Endl;} void input () {CIN> year> month> day;} void print () {cout <year <". "<month <". "<day <". "<Endl ;}~ Date () {cout <"date is ruined" <Endl ;}}; class people {PRIVATE: int number; int sex; Date birthday; int ID; public: people () {cout <"Create a people" <Endl <"Please input his number, sex (0 is man.1 is woman ), ID and birthday "<Endl;} People (People & A) {cout <" copy a people "<" \ n "; number =. number; Sex =. sex; Birthday =. birthday; id =. ID;} void input () {CIN> number> sex> ID; birthday. input ();} void print () {cout <numb Er <Endl <sex <Endl <id <Endl; birthday. Print ();}~ People () {cout <"people is Delete" <Endl ;}; void main () {People people1; people1.input (); people1.print (); people people2 (people1); people2.print ();}

The program runs as follows. It is estimated that the program looks at the Pan-pilot. Fortunately, the code is simple.

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.