Problem A: 你会定义类吗?
来源:互联网 发布:仰恩大学网络教务系统 编辑:程序博客网 时间:2024/05/21 19:35
Description
定义一个类Demo,有构造函数、析构函数和成员函数show(),其中show()根据样例的格式输出具体属性值。该类只有一个int类型的成员。
Input
输入只有一个整数,int类型范围内。
Output
见样例。
Sample Input
-100
Sample Output
A data 10 is created!A data 0 is created!A data -100 is created!This is data 10This is data 0This is data -100A data -100 is erased!A data 0 is erased!A data 10 is erased!
HINT
Append Code
append.cc,
#include <iostream>using namespace std;class Demo{private: int data;public: Demo(int _data = 0) { data = _data; cout << "A data "<< data <<" is created!" << endl; } void show() { cout << "This is data " << data << endl; } ~Demo() { cout << "A data "<< data <<" is erased!" << endl; }};int main(){ Demo tmp(10), tmp2; int d; cin>>d; Demo tmp3(d); tmp.show(); tmp2.show(); tmp3.show(); return 0;}
0 0
- Problem A: 你会定义类吗?
- Problem A: 你会定义类吗?
- Problem A: 你会定义类吗?
- Problem A: 你会定义类吗?
- js定义类,你会吗?
- 第十五周oj刷题——Problem A: 长方柱类【C++ 类定义】
- 你会打电话吗
- 你会讲故事吗?
- 你会“还礼”吗?
- 你会做人吗
- 你会睡觉吗
- 你会说话吗
- 你会休息吗?
- 软件设计,你会吗?
- 提问,你会吗?
- 你会Flex吗?
- 你会“学习”吗
- 你会画图吗?
- MatchNet: Unifying Feature and Metric Learning for Patch-Based Matching
- 通过注册表修改IE的Internet选项
- ubuntu安装nginx及配置nginx
- 安卓通过自定义view实现水波进度条控件
- ios
- Problem A: 你会定义类吗?
- 剑指offer:第5题从尾到头打印链表
- Python list clear
- 云安全之Neutron 是如何实现虚机防火墙的 [How Neutron Implements Security Group]
- 国务院关于做好省级以下国土资源管理体制改革有关问题的通知-国发(2004)12号
- Notes on NNDL(Neural Networks and Deep Learning)
- [Leetcode] 11. Container With Most Water
- 求三位数相乘的最大回文数?
- java获取http请求页面的内容的两种方法