> 其他 >
C++问题:定义一个Rectangle类,包括两个数据成员length和width,以及用于求长方形面积的成员函数.
再定义Rectangle的派生类Rectangular,它包括一个新数据成员height和用来求长方体体积的成员函数.在main函数中,使用两个类,求某个长方形的面积和某个长方体的体积.
人气:418 ℃ 时间:2019-12-10 06:32:06
解答
#includeusing namespace std;class Rectangle{protected:double length,width;public:Rectangle(double a,double b):length(a),width(b){}double area(){return length*width;}};class Rectangular:publiv class Re...
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版