3-2 构造函数的调用-SDUT
来源:互联网 发布:mac打开csgo黑屏 编辑:程序博客网 时间:2024/05/17 06:07
<span style="font-size:24px;">3-2 构造函数的调用 </span>
题目描述
通过本题目的练习可以掌握构造函数和析构函数的调用;
创建类A;类中仅包含构造函数和析构函数,按照程序的输出写出类的定义和主函数main中的代码。
输入
无
输出
输出数据有4行,分别代表对构造函数和析构函数的调用;本练习要求所编写程序的输出必须与示例相同。
示例输入
无
示例输出
Constructing an object of AConstructing an object of ADestructing an object of ADestructing an object of A
#include <iostream>
#include <string>
using namespace std;
class out
{
private:
string s;
public:
out(string a)
{
s = a;
}
~out()
{
cout<<"Destructing an object of A"<<endl;
cout<<"Destructing an object of A"<<endl;
}
void display()
{
cout<<s<<endl;
cout<<s<<endl;
}
};
int main()
{
out d("Constructing an object of A");
d.display();
return 0;
}
0 0
- sdut 3-2 构造函数的调用
- 3-2 构造函数的调用-SDUT
- SDUT-2671 3-2 构造函数的调用
- sdut 3-3 构造函数的调用(高级)
- 3-3 构造函数的调用(高级)--SDUT
- SDUT-2672 3-3 构造函数的调用(高级)
- [2670]3-1 Point类的构造函数 SDUT
- sdut 3-1 Point类的构造函数
- sdut 5-3 多级派生类的构造函数
- sdut 5-3 多级派生类的构造函数
- 3-1 Point类的构造函数-SDUT
- SDUT-2670 3-1 Point类的构造函数
- SDUT-2713-->5-3 多级派生类的构造函数
- SDUT 2712 5-2 派生类的构造函数
- sdut 5-2 派生类的构造函数
- sdut 5-2 派生类的构造函数
- SDUT-2712-->5-2 派生类的构造函数
- 3-2 构造函数的调用
- jquery实现菜单树
- 蚕吃桑叶吐丝,蜂采花酿蜜,人吃饭长精神
- js 页面刷新location.reload和location.replace的区别小结
- 看了handler源码后,对其用法及原理的一点分析
- 安卓控件getRawX与getX区别
- 3-2 构造函数的调用-SDUT
- iOS9之前,UINavigationController控制器子类无法控制器StatusBar的样式
- MySQL安装设置详细教程
- 10 个让程序员放松的网站
- C++的继承与派生:公有,私有,保护
- 浏览器与HTTP网络协议缓存原理分析 转自网界网:http://news.cnw.com.cn/news-china/htm2015/20151027_322909.shtml
- 场景二:synchronized修饰方法
- monkeyrunner自动化测试工具--录制回放
- Spring随笔3