Problem A: 第一个类

来源:互联网 发布:python搭建web服务器 编辑:程序博客网 时间:2024/06/06 23:51
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]
#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;}

0 0
原创粉丝点击