#include using namespace std; class Rect { protected: double length; double width; public: Rect(double l, double w) : length(l), width(w) {} double area() { return length * width; } }; class Cub : public Rect { private: double height; public: Cub(double l, double w, double h) : Rect(l, w), height(h) {} double surfaceArea() { return 2 * (area() + length * height + width * height); } double volume() { return area() * height; } void print() { cout << "length=" << length << " width=" << width << " height=" << height << endl; cout << "表面积=" << surfaceArea() << " 体积=" << volume() << endl; } }; int main() { double l, w, h; cout << "输入长方体的长、宽、高:" << endl; cin >> l >> w >> h; Cub cub(l, w, h); cub.print(); return 0; }