main.cpp

来自「一本语言类编程书籍」· C++ 代码 · 共 21 行

CPP
21
字号
// Exercise 15.3 By addng a few lines to the test program, we can see the difference 
// between the calls to the base class and derived class who() functions. 

#include "Animal.h"
#include <iostream>
using std::cout;
using std::endl;

int main() {
  Lion myLion("Leo", 400);
  Aardvark myAardvark("Algernon", 50);
  cout << "\nCalling derived versions of who():";
  myLion.who();
  myAardvark.who();

  cout << "\n\nCalling base versions of who():";
  myLion.Animal::who();
  myAardvark.Animal::who();
  cout << endl;
  return 0;
}

⌨️ 快捷键说明

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