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

📄 c48.cpp

📁 此文件可以能帮你求体积
💻 CPP
字号:
// c48.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include <iostream.h>

// --------------------------------------------------------------------------
class Vehicle
{
public:
	Vehicle( int w, int r ) : numWheels( w ), range( r ){}
	void ShowV()
	{
		cout << "Wheels: " << numWheels << endl;
		cout << "Range: " << range << endl;
	}
private:
	int numWheels;
	int range;
};

// --------------------------------------------------------------------------
class Car : public Vehicle
{
public:
	Car( int p, int w, int r ) : Vehicle( w, r ), passengers( p ){}
	void ShowV()
	{
		cout << "\nCar: \n";
		Vehicle::ShowV();
		cout << "Passengers: " << passengers << endl;
	}
private:
	int passengers;
};

// --------------------------------------------------------------------------
class Truck : public Vehicle
{
public:
	Truck( int l, int w, int r ):Vehicle( w, r ), loadLimit(l) {}
	void ShowV()
	{
		cout << "\nTruck: \n";
		Vehicle::ShowV();
		cout << "load limit: " << loadLimit << endl;
	}
private:
	int loadLimit;
};

// --------------------------------------------------------------------------
int main(int argc, char* argv[])
{
	Car c( 5, 4, 500 );
	Truck t( 30000, 12, 1200 );

	c.ShowV();
	t.ShowV();

	return 0;
}

⌨️ 快捷键说明

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