c++课后题,定义一个国家基类Country,包含国名,首都,人口等属性,派生出省类P类,增加…………
头文件名Country.h
头文件内容:
#ifndef Country_h
#define Country_h
#include<iostream>
#include<string>
using namespace std;
class Country //国家类
{
public:
void Country_name_in(string name)
{
cout << "请输入国家的名字:" << endl;
cin >> name;
Country_name = name;
}
void capital_name_in(string name)
{
cout << "请输入国家的首都:" << endl;
cin >> name;
capital = name;
}
void Country_population(int i)
{
cout << "请输入国家的人口:" << endl;
cin >> i;
population = i;
}
private:
string Country_name;
string capital;
int population;
};
class Province :public Country//公开声明派生类省
{
public:
void Province_name_in(string name)
{
cout << "请输入省的名字:" << en