您的位置:首页 > 其它

Problem A: 第一个类

2017-05-14 12:06 204 查看
HomeWeb BoardProblemSetStandingStatusStatistics

Problem A: 第一个类

Time Limit: 1 Sec  Memory Limit:
128 MB
Submit: 730  Solved: 669

[Submit][Status][Web
Board]

Description

定义一个Thing类,只有1个字符串属性name,定义其构造函数和析构函数,分别输出样例所示的内容。

Input

一个不包含空白符的字符串。

Output

见样例。

Sample Input

Truck

Sample Output

Construct a thing CarConstruct a thing TruckDestroy a thing TruckDestroy a thing Car

HINT

Append Code

append.cc,

[Submit][Status][Web
Board]

한국어<  中文 فارسی 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>
#include <iomanip>
#include <cstring>
#include <cmath>
using namespace std;
class Thing
{
private:
string name;
public:
Thing(){ }
Thing(string n):name(n) {cout << "Construct a thing " << name << endl; }
~Thing(){ cout << "Destroy a thing " << name << endl;}
};
int main()
{
Thing A("Car");
string str;
cin>>str;
Thing B(str);
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: