box.h
来自「一本语言类编程书籍」· C头文件 代码 · 共 27 行
H
27 行
// Box.h definition of the Box class
#ifndef BOX_H
#define BOX_H
#include <iostream>
using std::cout;
using std::ostream;
class Box {
public:
Box(double lv = 1.0, double wv = 1.0, double hv = 1.0) :
length(lv), width(wv), height(hv) {}
double volume() const { return length*width* height; }
bool operator<(const Box& x) const { return volume() < x.volume(); }
friend ostream& operator<<(ostream& out, const Box& box) {
out << "(" << box.length << "," << box.width << "," << box.height << ")";
return out;
}
private:
double length;
double width;
double height;
};
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?