#include <iostream> using namespace std; class Cube { // write your code here...... private: int length,width,height;//先定义三个私有变量,仅在类内可以显示 public: void setHeight(int a){ height=a;//传入height值 } void setWidth(int b){ width=b;//传入width值 } void setLength(int c){ length=c;//传入length值 } int getLength(){ return length;//显示length } int getWidth(){ return width;//显示width } int getHeight(){ return height;//显示height } int getArea(){ return (width*height+length*height+width*length)*2;//计算出面积 } int getVolume(){ return width*height*length;//计算出体积 } }; int main() { int length, width, height; cin >> length;//传入实参length cin >> width;//传入实参width cin >> height;//传入实参height Cube c; c.setLength(length); c.setWidth(width); c.setHeight(height);//传出实参 cout << c.getLength() << " " << c.getWidth() << " " << c.getHeight() << " " << c.getArea() << " " << c.getVolume() << endl;//显示各方面的值 return 0; }