题解 | 设计立方体类
#include <iostream> #include <pthread.h> using namespace std; class Cube { private: int length; int width; int height; public: Cube () { cin>>length; cin>>width; cin>>height; } void print() { int S=(length *width+length*height+width*height)*2; int V=height*width*length; cout<<length<<" "<<width<<" "<<height<<" "<<S<<" "<<V<<endl; } }; int main() { Cube obj; obj.print(); return 0; }