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

📄 5-1.txt

📁 对卡车和小汽车的重量进行判断
💻 TXT
字号:
#include<iostream.h>
class Vehicle
{
protected:
	int wheels,weight;
public:
	Vehicle(int wh,int we)
	{
		wheels=wh;
		weight=we;
	}
	void disp()
	{
		cout<<"wheels is:"<<wheels<<endl;
		cout<<"weight is:"<<weight<<endl;
	}
};
class Car:private Vehicle
{
	int passenger_load;
public:
	Vehicle::disp;
	Car(int wh,int we,int pas):Vehicle(wh,we)
	{
		passenger_load=pas;
	}
	void show()
	{
		cout<<"The car's wheels is:"<<wheels<<endl;
		cout<<"The car's weight is:"<<weight<<endl;
		cout<<"The car's passage_load is:"<<passenger_load<<endl;
		cout<<"	"<<endl;
}
};
class Truck:private Vehicle
{
	int passenger_load,pay_load;
public:
	Vehicle::disp;
	Truck(int wh,int we,int pas,int pay):Vehicle(wh,we)
	{
		passenger_load=pas;
		pay_load=pay;
	}
	void show()
	{	
		cout<<"The truck's wheels is:"<<wheels<<endl;
		cout<<"The truck's weight is:"<<weight<<endl;
		cout<<"The truck's passage_load is:"<<passenger_load<<endl;
		cout<<"The truck's pay_load is:"<<pay_load<<endl;
		cout<<"	"<<endl;
}
};
void main()
{
	Car c(4,5000,4); 
	c.disp();
	c.show();
	
	Truck t(6,8000,2,5000);
	t.disp();
	t.show();
	
}

⌨️ 快捷键说明

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