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

📄 prog16_07.cpp

📁 c++最经典的入门书籍
💻 CPP
字号:
// Program 16.7 Using an indirect base class  File: prog16_07.cpp
#include <iostream>
#include "Box.h"                                    // For the Box class
#include "ToughPack.h"                              // For the ToughPack class
#include "Carton.h"                                 // For the Carton class
#include "Can.h"                                    // for the Can class
using std::cout;
using std::endl;

int main() {
  Box aBox(40, 30, 20);
  Can aCan(10, 3);
  Carton aCarton(40, 30, 20);
  ToughPack hardcase(40, 30, 20);

  Vessel* pVessels[] = { &aBox, &aCan, &aCarton, &hardcase };

  cout << endl;
  for(int i = 0 ; i < sizeof pVessels / sizeof(pVessels[0]) ; i++)
    cout << "Volume is " << pVessels[i]->volume() << endl;

  return 0;
}

⌨️ 快捷键说明

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