Python 官方文档:入门教程 => 点击学习
HomeWEB BoardProblemSetStandingStatusStatisticsProblem A: 还会用继承吗?Time Limit: 1 Sec Memory Limit: &n
Home | WEB Board | ProblemSet | Standing | Status | Statistics |
Time Limit: 1 Sec
Memory Limit: 128 MB
Submit: 1756
Solved: 1255
[ Submit][Status][Web Board]
定义一个Base类,包括1个int类型的属性,以及满足输出格式要求的构造函数、拷贝构造函数和析构函数。
定义Base类的子类Derived,包括1个int类型的属性, 以及满足输出格式要求的构造函数、拷贝构造函数和析构函数。
第1行N>0表示测试用例个数。
每个测试包括2个int类型的整数。
见样例。
110 20
Base = 10 is created.Base = 10 is copied.Base = 10 is created.Derived = 20 is created.Base = 10 is copied.Derived = 20 is copied.Derived = 20 is erased.Base = 10 is erased.Derived = 20 is erased.Base = 10 is erased.Base = 10 is erased.Base = 10 is erased.
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>
using namespace std;
class Base
{
protected:
int x_;
public:
Base(int x = 0) : x_(x){ cout << "Base = " << x_ << " is created." << endl;}
Base(const Base & b) : x_(b.x_) { cout << "Base = " << x_ << " is copied." << endl; }
~Base(){ cout << "Base = " << x_ << " is erased." << endl; }
};
class Derived :public Base
{
private:
int y_;
public:
Derived(int x, int y) : Base(x),y_(y) { cout << "Derived = " << y_ << " is created." << endl; }
Derived(const Derived & d) : Base(d),y_(d.y_) { cout << "Derived = " << y_ << " is copied." << endl; }
~Derived(){ cout << "Derived = " << y_ << " is erased." << endl; }
};
int main()
{
int cases, data1, data2;
cin>>cases;
for (int i = 0; i < cases; i++)
{
cin>>data1>>data2;
Base base1(data1), base2(base1);
Derived derived1(data1, data2), derived2(derived1);
}
}
--结束END--
本文标题: Problem A: 还会用继承吗?
本文链接: https://www.lsjlt.com/news/218563.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
一口价域名售卖能注册吗?域名是网站的标识,简短且易于记忆,为在线用户提供了访问我们网站的简单路径。一口价是在域名交易中一种常见的模式,而这种通常是针对已经被注册的域名转售给其他人的一种方式。
一口价域名买卖的过程通常包括以下几个步骤:
1.寻找:买家需要在域名售卖平台上找到心仪的一口价域名。平台通常会为每个可售的域名提供详细的描述,包括价格、年龄、流
443px" 443px) https://www.west.cn/docs/wp-content/uploads/2024/04/SEO图片294.jpg https://www.west.cn/docs/wp-content/uploads/2024/04/SEO图片294-768x413.jpg 域名售卖 域名一口价售卖 游戏音频 赋值/切片 框架优势 评估指南 项目规模 安全指南 Osprey 游戏分析 游戏调试 游戏图形 游戏物理 开源库
0