Tutorial 12: Problem A: Will you define A class ?, Problem definition

Source: Internet
Author: User

Tutorial 12: Problem A: Will you define A class ?, Problem definition

Home Web Board ProblemSet Standing Status Statistics
  Problem A: Will you define A class? Problem A: Will you define A class? Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 556 Solved: 464
[Submit] [Status] [Web Board] Description

Define a Demo class, including constructor, destructor, and member function show (). show () outputs the specific attribute values according to the format of the sample. This class has only one int type member.

 

Input

The input must be an integer within the int type.

 

Output

See the example.

 

Sample Input-100Sample OutputA data 10 is created! A data 0 is created! A data-100 is created! This is data 10 This is data 0 This is data-100A data-100 is erased! A data 0 is erased! A data 10 is erased! HINT Append Codeappend. cc, [Submit] [Status] [Web Board]

Please refer to the following link for more information:
All Copyright Reserved 2010-2011 SDUSTOJ TEAM
GPL2.0 2003-2011 HUSTOJ Project TEAM
Anything about the Problems, Please Contact Admin: admin

#include<iostream>using namespace std;class Demo{public:    int x;    Demo(int a=0):x(a){cout<<"A data "<<x<<" is created!"<<endl;}    ~Demo(){cout<<"A data "<<x<<" is erased!"<<endl;}    void show(){cout<<"This is data "<<x<<endl;}};int main(){    Demo tmp(10), tmp2;    int d;    cin>>d;    Demo tmp3(d);    tmp.show();    tmp2.show();    tmp3.show();    return 0;}

 

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.