⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prog8.cpp

📁 C++语言程序设计题典
💻 CPP
字号:
#include <iostream.h>
#include <iomanip.h>
#include <string.h>
class Building
{
protected:
	char bname[10]; //名称
	int fs;         //层数
	int rs;         //教室个数或住户数
	int es;         //灭火器数或总人数
	double as;      //总面积
public:
	Building(char b[],int f,int r,int e,int a)
	{
		strcpy(bname,b);
		fs=f;rs=r;es=e;as=a;
	}
};
class hostel:public Building
{
public:
	hostel(char b[],int f,int r,int e,int a):Building(b,f,r,e,a) {}
	void disp()
	{
		cout << "宿舍名称:" << bname << endl;
		cout << "  总层数:  " << setw(4) << fs << "  住户数:" << rs << endl;
		cout << "  总住人数:" << setw(4) << es << "  总面积:" << as << endl;
	}
};
class classroom:public Building
{
public:
	classroom(char b[],int f,int r,int e,int a):Building(b,f,r,e,a) {}
	void disp()
	{
		cout << "教学楼名称:" << bname << endl;
		cout << "  总层数:  " << setw(4) << fs << "  教室数:" << rs << endl;
		cout << "  灭火器数:" << setw(4) << es << "  总面积:" << as << endl;
	}
};
void main()
{
	hostel h("57栋",8,32,120,3000);
    classroom r("5号楼",5,62,20,6000);
	h.disp();
	r.disp();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -