dev-c++代码哪里错了? - 爱问答

(爱问答)

dev-c++代码哪里错了?

#include <iostream>

using namespace std;

class Rectangle

{

public:

Rectangle (double l,double w){length=l,width=w}

double area(){return length*width;}

void display1();

private:

double length;

double width;

};

void Rectangle::display1()

{cout<<"长 :"<<length<<endl;

cout<<"宽 :"<<width<<endl;}

class Cuboid:public Rectangle

{

public:

Cuboid (double L,double w,double h):Rectangle(L,w){high=h,volume=L*w*high }; double vol(){return area()*high;}

void show ();

private:

double high;

double volume;

};

void Cuboid::show()

{

display1();

cout<<"高 :"<<high<<endl;

cout<<"体积 :"<<vol()<<endl;

}

void main()

{

Cuboid cub (10,20,30);

cub.show();

}


程序有两处错

Rectangle (double l,double w){length=l,width=w}

正确的

Rectangle (double l,double w){length=l;width=w;}

Cuboid (double L,double w,double h):Rectangle(L,w){high=h,volume=L*w*high }; double vol(){return area()*high;}

正确的

Cuboid (double L,double w,double h):Rectangle(L,w){high=h;volume=L*w*high; }; double vol(){return area()*high;}

注意分号

结果

长 :10

宽 :20

高 :30

体积 :6000


下一篇:那请问vs2017和2010是2017好用吗,还是说国考只能用2010,我不太了解,见谅

上一篇:在国外怎么象国内一样使用小米盒子3增强型。

热门标签:
excel 网盘 破解 word dll
最新更新:
微软重新评估新的Outlook的使用时机 联想推出搭载联发科Helio G80芯片组的Tab M9平板 英特尔创新大赛时间确定! 微软Edge浏览器在稳定渠道中推出Workspaces功能 英伟达RTX4060TiGPU推出MaxSun动漫主题! 谷歌地图为用户提供了街景服务! GameSir 在T4 Kaleid中推出了一款出色的控制器! 微软开始在Windows 11 中测试其画图应用程序的新深色模式! LG电子推出全球首款无线OLED电视 英伟达人工智能芯片崭露头角! Steam Deck可以玩什么游戏-Steam Deck价格限时优惠 雷蛇推出CobraPro鼠标 Kindle电子阅读器可以访问谷歌商店吗 Windows10如何加入组策略 window10图片查看器怎么没有了?