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

📄 list1201.cpp

📁 teach yourself C++ in 21 days 第五版
💻 CPP
字号:
//Listing 12.1 Simple inheritance
#include <iostream>
using namespace std;

enum BREED { GOLDEN, CAIRN, DANDIE, SHETLAND, DOBERMAN, LAB };

class Mammal
{
  public:
    // constructors
    Mammal();
    ~Mammal();

    //accessors
    int GetAge()	 const;
    void SetAge(int);
    int GetWeight() const;
    void SetWeight();

    //Other methods
    void Speak() const;
    void Sleep() const;


  protected:
    int itsAge;
    int itsWeight;
};

class Dog : public Mammal
{
  public:

    // Constructors
    Dog();
    ~Dog();

    // Accessors
    BREED GetBreed() const;
    void  SetBreed(BREED);

    // Other methods
    WagTail();
    BegForFood();

  protected:
    BREED itsBreed;
};

⌨️ 快捷键说明

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