animal.h

来自「一本语言类编程书籍」· C头文件 代码 · 共 29 行

H
29
字号
// Exercise 15.1 - 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){}
};

class Aardvark: public Animal {
  public:
    Aardvark(string theName, int wt):Animal(theName, wt){}
};

#endif

⌨️ 快捷键说明

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