prog12_08.cpp
来自「一本语言类编程书籍」· C++ 代码 · 共 33 行
CPP
33 行
// Program 12.8 Creating an array of Box objects File: prog12_08.cpp
#include <iostream>
#include "Box.h"
using std::cout;
using std::endl;
int main() {
cout << endl;
Box firstBox(17.0, 11.0, 5.0);
Box boxes[5];
cout << "Volume of first box = "
<< firstBox.volume()
<< endl;
const int count = sizeof boxes/sizeof boxes[0];
cout << "The boxes array has " << count << " elements."
<< endl;
cout << "Each element occupies " << sizeof boxes[0] << " bytes."
<< endl;
for(int i = 0 ; i < count ; i++)
cout << "Volume of boxes[" << i << "] = "
<< boxes[i].volume()
<< endl;
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?