24小时热门版块排行榜    

查看: 1325  |  回复: 5
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

cw277

木虫 (正式写手)

[求助] 这个c++小程序编译的错误很奇怪~~

明明语法上应该没有错误~~
回复此楼

» 本帖附件资源列表

  • 欢迎监督和反馈:小木虫仅提供交流平台,不对该内容负责。
    本内容由用户自主发布,如果其内容涉及到知识产权问题,其责任在于用户本人,如对版权有异议,请联系邮箱:xiaomuchong@tal.com
  • 附件 1 : 程序.rar
  • 2012-09-26 16:05:12, 86.56 K

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

感谢生活让我慢慢学会控制自己的情绪,学会包容与忍耐,学会不再去期待
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

suhhyuan

铁虫 (初入文坛)

哦,出了一个bug,不好意思。
吧第三步中的

#include

应该为

#include
6楼2012-10-02 11:11:32
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 6 个回答

libralibra

至尊木虫 (著名写手)

骠骑将军

【答案】应助回帖


感谢参与,应助指数 +1
cw277: 金币+1, 有帮助, 文件有好几个。 2012-09-26 18:22:54
直接把代码贴在贴子里吧
matlab/VB/python/c++/Java写程序请发QQ邮件:790404545@qq.com
2楼2012-09-26 17:35:36
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

bemoner

金虫 (正式写手)

把代码贴出来,帮你看一下!
3楼2012-09-26 22:37:22
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

cw277

木虫 (正式写手)

cw277: 回帖置顶 2012-09-27 08:46:54
代码如下:

//POINT.H
#ifndef _POINT_H
#define _POINT_H

class Point
{public:
  Point(float=0,float=0);
  void setPoint(float,float);
  float getX() const {return x;}
  float getY() const {return y;}
  friend ostream & operator<<(ostream &,const Point &;
protected:
  float x,y;
};
#endif


//CIRCLE.H
#include "point.h"
#ifndef _CIRCLE_H
#define _CIRCLE_H

class Circle:public Point
{public:
  Circle(float x=0,float y=0,float r=0);
  void setRadius(float);
  float getRadius() const;
  float area () const;
  friend ostream &operator<<(ostream &,const Circle &;
protected:
  float radius;
};
#endif

//CYLINDER.H
#include "circle.h"
#ifndef _CYLINDER_H
#define _CYLINDER_H

class Cylinder:public Circle
{public:
  Cylinder (float x=0,float y=0,float r=0,float h=0);
  void setHeight(float);
  float getHeight() const;
  float area() const;
  float volume() const;
  friend ostream& operator<<(ostream&,const Cylinder&;
protected:
  float height;
};
#endif


//POINT.CPP
#include "point.h"
Point:oint(float a,float b)
{x=a;y=b;}

void Point::setPoint(float a,float b)
{x=a;y=b;}

ostream & operator<<(ostream &output,const Point &p)
{output<<"["< return output;
}


//CIRCLE.CPP
//#include
#include "circle.h"
Circle::Circle(float a,float b,float r)oint(a,b),radius(r){}

void Circle::setRadius(float r)
{radius=r;}

float Circle::getRadius() const {return radius;}

float Circle::area() const
{return 3.14159*radius*radius;}

ostream &operator<<(ostream &output,const Circle &c)
{output<<"Center=["< return output;
}


//CYLINDER.CPP
#include "cylinder.h"

Cylinder::Cylinder(float a,float b,float r,float h)
    :Circle(a,b,r),height(h){}

void Cylinder::setHeight(float h){height=h;}

float Cylinder::getHeight() const {return height;}

float Cylinder::area() const
{ return 2*Circle::area()+2*3.14159*radius*height;}

float Cylinder::volume() const
{return Circle::area()*height;}

ostream &operator<<(ostream &output,const Cylinder& cy)
{output<<"Center=["<        <<"\narea="< return output;
}

///main.cpp
#include      //如用VC++应改为∶#include  
using namespace std;    //如用VC++应取消此行
#include "point.h"
#include "circle.h"
#include "cylinder.h"
#include "point.cpp"
#include "circle.cpp"
#include "cylinder.cpp"
int main()
{Cylinder cy1(3.5,6.4,5.2,10);
cout<<"\noriginal cylinder:\nx="<      <      <<", volume="< cy1.setHeight(15);
cy1.setRadius(7.5);
cy1.setPoint(5,5);
cout<<"\nnew cylinder:\n"< Point &pRef=cy1;
cout<<"\npRef as a point:"< Circle &cRef=cy1;
cout<<"\ncRef as a Circle:"< return 0;
}
感谢生活让我慢慢学会控制自己的情绪,学会包容与忍耐,学会不再去期待
4楼2012-09-27 08:46:15
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[基金申请] 投票:  有多少人是今天查系统知道结果的? +17 爱看书的可乐 2026-08-26 19/950 2026-09-02 00:19 by xiangy672
[基金申请] 学科评审组评审是指会评吗? +4 瞬息宇宙 2026-08-31 4/200 2026-09-01 14:58 by jiaoxg
[基金申请] 为什么资助数各大高校都创新高,自己申请怎么就这么难 +13 Kittylucky 2026-08-27 14/700 2026-09-01 11:06 by feng6531
[基金申请] 麻烦专家们看看评委们的意见(F口面上) +7 gdd2018 2026-08-28 12/600 2026-09-01 08:32 by 尼古拉斯小虫
[基金申请] 国社科又开始会评了,不知道这次命运如何 +7 雨打竹帘 2026-08-30 11/550 2026-08-31 23:16 by hittle2008
[基金申请] 基金未中,这种答复是模板吗? +6 zhaosm1982 2026-08-27 7/350 2026-08-31 21:18 by qdxxmc
[基金申请] 哪位高人中了,把查询到的截图贴出来让我看看,让我长长见识 +6 yuleib84 2026-08-26 7/350 2026-08-31 19:46 by 鱼翔浅底1
[基金申请] 面上意见出来了 +12 黄鸟于飞Chao 2026-08-29 23/1150 2026-08-31 18:57 by 黄鸟于飞Chao
[基金申请] 为什么到现在没收到通知? +5 tannykie 2026-08-29 5/250 2026-08-30 21:05 by purplejack
[基金申请] 有没有仍没收到信息的 +7 德尚中行 2026-08-27 8/400 2026-08-30 20:52 by purplejack
[基金申请] 我就是申请一个面上项目而已,这评审意见是按照杰青的条件评的吧? +6 gouxfjh 2026-08-28 11/550 2026-08-30 07:57 by gouxfjh
[基金申请] 国自然面上复盘~欢迎讨论 (金币+15) +15 晴天加油 2026-08-26 16/800 2026-08-29 18:28 by symmetry
[基金申请] 国自然评审意见 +13 wangmingqi 2026-08-28 19/950 2026-08-29 10:22 by Poppy1104
[基金申请] 怎么查啊 +6 huang1991js 2026-08-26 6/300 2026-08-28 08:42 by winsaint
[基金申请] 看板上这么多中的,有点像50人群里49个人都是骗子的那种感觉…… +5 a089 2026-08-26 6/300 2026-08-27 14:05 by jonewore
[基金申请] 为什么 国际(地区)合作与交流项目 没有放榜? 10+3 majunge000 2026-08-26 11/550 2026-08-27 08:42 by 北京莱茵编辑
[基金申请] 我不理解! +15 Edward_pc 2026-08-26 23/1150 2026-08-26 20:34 by zzuzxg
[基金申请] 国合里面能看到了 +7 一怀馨秋 2026-08-26 7/350 2026-08-26 11:23 by zhaosm1982
[基金申请] 国际合作可查了,中了面上 (EPI+1)(金币+50) +18 Ldrop2023 2026-08-26 18/900 2026-08-26 11:15 by cmrandy
[基金申请] 项目信息和经费信息在系统里都可以看到了 +6 wittyboy 2026-08-26 14/700 2026-08-26 10:55 by wittyboy
信息提示
请填处理意见