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

📄 animal.h

📁 一本语言类编程书籍
💻 H
字号:
// Exercise 15.3 - Animal.h
// Animal class and classes derived from Animal

#ifndef ANIMAL_H
#define ANIMAL_H
#include <string>
using std::string;

class Animal {
  public:
    Animal(string theName, int wt);   // Constructor
    void who() const;                 // Display name and weight

  private:
    string name;                      // Name of the animal
    int weight;                       // Weight of the animal
};

class Lion: public Animal {
  public:
    Lion(string theName, int wt):Animal(theName, wt){}
    void who() const;      // Public member to access protected base function
};

class Aardvark: public Animal {
  public:
    Aardvark(string theName, int wt):Animal(theName, wt){}
    void who() const;      // Public member to access protected base function
};

#endif

⌨️ 快捷键说明

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