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

📄 ch11animals.h

📁 此例子是学习C++的好东西
💻 H
字号:
//Program 11-11 The Animals

//File: Ch11Animals.cpp

#ifndef  _ANIMALS_H
#define  _ANIMALS_H


#include <string>
using namespace std;

class Date
{
private:
	int mon,day,yr;
public:
	Date(){mon = 1; day = 1; yr = 2000; };
	void SetDate(int m, int d, int y);
	void ShowDate();
};

enum Category { mammal, fish, bird, reptile, amphibian, insect };
enum Species { dog, cat, scrubjay, sparrow, frog, toad };

class Animal
{
protected:
	string name;
	Species whatIam;
	Date birth;
	Category type;
public:
	Animal(Category t, Species s, string n, Date b);
	void Write();
};

class Mammal : public Animal
{
private:
	double height;
public:
	Mammal(Category t, Species s, string n,Date b, double h);
	void SayHello();
	void FavoriteFood();
};

class Bird: public Animal
{
private:
	double wingspan;
public:
	Bird(Category t, Species s, string n,Date b, double w);
	void SayHello();
	void FavoriteFood();
};

class Amphibian: public Animal
{
private:
	double length;
public:
	Amphibian(Category t, Species s, string n,Date b, double l);
	void SayHello();
	void FavoriteFood();
};


#endif

⌨️ 快捷键说明

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