/*矩形类*/classRectangle{private:double L =0;double W =0;public:Rectangle()=default;Rectangle(double a,double b);doubleGetArea();/*矩形面积*/doubleGetGirth();/*矩形周长*/};/*构造函数*/Rectangle::Rectangle(double a,double b): L{ a }, W{ b }{}/*矩形面积*/doubleRectangle::GetArea(){double S = L * W;return S;}/*矩形周长*/doubleRectangle::GetGirth(){double L =2*(this->L + W);return L;}
Cuboid长方体类
/*长方体类*/classCuboid:publicRectangle{private:double H =0;public:Cuboid()=default;Cuboid(double a,double b,double c);doubleGetVolume();/*长方体体积*/doubleGetSurfaceArea();/*长方体表面积*/};/*构造函数*/Cuboid::Cuboid(double a,double b,double c): Rectangle{ a,b }, H{ c }{}/*长方体体积*/doubleCuboid::GetVolume(){double V = H *GetArea();return V;}/*长方体表面积*/doubleCuboid::GetSurfaceArea(){double S =2*GetArea()+ H *GetGirth();return S;}
🌷🍁 博主猫头虎 带您 Go to New World.✨🍁 🦄 博客首页——猫头虎的博客🎐 🐳《面试题大全专栏》 文章图文并茂🦕生动形象🦖简单易学!欢迎大家来踩踩~🌺 &a…