ch11twovehicles.cpp

来自「此例子是学习C++的好东西」· C++ 代码 · 共 60 行

CPP
60
字号
//Program 11-15 Two Vehicles

// File:  Ch11TwoVehicles.cpp

#include <iostream>
#include "Ch11TwoVehicles.h"


void Vehicle::GetInfo()
{
	cout << " \nEnter owner's name:  ";
	cin.getline(owner,50);
	cout << "\nEnter license plate such as NM 123 ABC :  ";
	cin.getline(license,50);
}

void Vehicle::WriteInfo()
{
	char TypeNames[2][15] = { "recreational","commercial" };
	cout << "\n\n        Owner: " << owner <<
		    "\n      License: " << license;

}

void RV::GetInfo()
{

	cout << "\n Please enter information for the recreational vehicle.";
	Vehicle::GetInfo();		//call the base class GetInfo first
	char enter;
	cout << "\nEnter RV category  1, 2 or 3 ";
	cin >> category;
	cin.get(enter);			// pull off enter key left by cin

}

void RV::WriteInfo()
{
	Vehicle::WriteInfo();
	cout << "\n This RV is a category " << category;

}

void Semi::GetInfo()
{
	cout << "\n Please enter information for the commercial vehicle.";
	Vehicle::GetInfo();
	char enter;
	cout << " \n Enter the weight capacity ";
	cin >> weight_cap;
	cin.get(enter);		// pull off enter key left by cin

}

void Semi::WriteInfo()
{
	Vehicle::WriteInfo();
	cout << "\n This commercial vehicle has a weight capacity of " << weight_cap;
}

⌨️ 快捷键说明

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