m0_67630084 2022-04-09 16:58 采纳率: 100%
浏览 18
已结题

代码错了,但是不知道应该怎么改,想问一下

#include
using namespace std;
class Box
{
private:double length;
double breadth;
double height;
};
int main( )
{
Box Box1;
Box Box2;
double volume = 0.0;
Box1.height = 5.0;
Box1.length = 6.0;
Box1.breadth = 7.0;
Box2.height = 10.0;
Box2.length = 12.0;
Box2.breadth = 13.0;
volume = Box1.height * Box1.length * Box1.breadth;
cout << "Box1 的体积:" << volume <<endl;
volume = Box2.height * Box2.length * Box2.breadth;
cout << "Box2 的体积:" << volume <<endl;
return 0;
}

  • 写回答

2条回答 默认 最新

  • CSDN专家-sinJack 2022-04-09 17:16
    关注
    #include<iostream> 
    using namespace std;
    class Box
    {
    public:
        double length;
        double breadth;
        double height;
    };
    int main()
    {
    Box Box1;
    Box Box2;
    double volume = 0.0;
    Box1.height = 5.0;
    Box1.length = 6.0;
    Box1.breadth = 7.0;
    Box2.height = 10.0;
    Box2.length = 12.0;
    Box2.breadth = 13.0;
    volume = Box1.height * Box1.length * Box1.breadth;
    cout << "Box1 的体积:" << volume <<endl;
    volume = Box2.height * Box2.length * Box2.breadth;
    cout << "Box2 的体积:" << volume <<endl;
    return 0;
    }
    

    img

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 4月23日
  • 已采纳回答 4月15日
  • 创建了问题 4月9日