定義一個類Demo,有構造函數、析構函數和成員函數show(),其中show()根據樣例的格式輸出具體屬性值。該類只有一個int類型的成員。
輸入只有一個整數,int類型范圍內。
見樣例。
한국어<
中文
فارسی
English
ไทย
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;
}