| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 469 人关注过本帖
标题:不知道这个程序为什么交不上去
只看楼主 加入收藏
haopeng123
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2007-5-12
收藏
 问题点数:0 回复次数:7 
不知道这个程序为什么交不上去

各位大哥大姐帮个忙啊!
这个程序在VC++上运行结果上正确的.但是在我们学校的交题系统确是编译错误:
Compile Error
54583\Main.cc: In function `int main()':
54583\Main.cc:68: error: no matching function for call to `Circle::Circle(int&, int&, Circle&)'
54583\Main.cc:32: note: candidates are: Circle::Circle(const Circle&)
54583\Main.cc:35: note: Circle::Circle(int, int, int)

Sample Input


R 10 20 10 20
C 20 10 10
R 3 3 4 5
E


Sample Output


Rectangle 1: Area=200 Perimeter=60 point=(10,20)
Circle 2: Area=314.159 Perimeter=62.8318 center point=(20,10)
Rectangle 3: Area=20 Perimeter=18 point=(3,3)

我的源代码如下:
#include<iostream.h>
#define PI 3.14159
class shape
{
int x,y;
public:

shape(int a,int b)
{x=a,y=b;}
virtual double GetArea()=0;
virtual double GetPerim()=0;
virtual void show()=0;
int getx()
{return x;}
int gety()
{return y;}
};
class Rectangle:public shape
{
protected:
int w,h;
public:
Rectangle(int a,int b,int c,int d);
double GetArea()
{return w*h;}
double GetPerim()
{return 2*(w+h);}
void show()
{cout<<": Area="<<GetArea()<<" Perimeter="<<GetPerim()<<" point=("<<shape::getx()<<","<<shape::gety()<<")"<<endl;}
};
Rectangle::Rectangle(int a,int b,int c,int d):shape(a,b),w(c),h(d)
{}
class Circle:public shape
{
protected:
int radius;
public:
Circle(int a,int b,int c):shape(a,b)
{radius=c;}
double GetArea()
{return PI*radius*radius;}
double GetPerim()
{return 2*PI*radius;}
void show()
{cout<<": Area="<<GetArea()<<" Perimeter="<<GetPerim()<<" center point=("<<shape::getx()<<","<<shape::gety()<<")"<<endl;}
};

int main()
{
int a,b,c,d,n=1;
//Rectangle r;
//Circle c;
char ch;
shape *p;
while(cin>>ch)
{
if(ch=='E') break;
if(ch=='R')
{
cin>>a>>b>>c>>d;
Rectangle r(a,b,c,d);
p=&r;
cout<<"Rectangle "<<n;
p->show();
//cout<<": Area="<<p->GetArea()<<" Perimeter="<<p->GetPerim()<<" point=("<<a<<","<<b<<")"<<endl;
n++;
// break;
}else if(ch=='C')
{
cin>>a>>b>>c;
Circle c(a,b,c);
p=&c;
cout<<"Circle "<<n;
p->show();
//cout<<": Area="<<p->GetArea()<<" Perimeter="<<p->GetPerim()<<" center point=("<<x<<","<<y<<")"<<endl;
n++;
// break;
}

}
return 0;
}

搜索更多相关主题的帖子: function matching 
2007-05-23 20:11
guang
Rank: 4
来 自:广东深圳
等 级:贵宾
威 望:13
帖 子:1414
专家分:285
注 册:2006-4-3
收藏
得分:0 
到C++区去吧

不相信未作牺牲竟先可拥有,只相信靠双手找到我的欲求!!
我的博客:http://liao5930.blog.
2007-05-23 21:20
飙马
Rank: 5Rank: 5
来 自:马里亚纳
等 级:贵宾
威 望:15
帖 子:779
专家分:280
注 册:2007-3-28
收藏
得分:0 
这是C#区呀!

IT精英如同彩票:平凡的人像5块也中不到一样普遍,努力一点你中了5元保了个本。奖金越高,机率也就越小,付出的也越多,盖茨如同500万一样稀有。虽然每天忙碌而平凡,但我努力成为精英,做梦中了500万。
2007-05-24 08:59
haopeng123
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2007-5-12
收藏
得分:0 
谢谢!
2007-05-24 09:32
bygg
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:乖乖的心中
等 级:版主
威 望:241
帖 子:13555
专家分:3076
注 册:2006-10-23
收藏
得分:0 
这是C#???LZ没什么吧??

飘过~~
2007-05-24 11:13
jacklee
Rank: 7Rank: 7Rank: 7
来 自:XAplus
等 级:贵宾
威 望:32
帖 子:1769
专家分:104
注 册:2006-11-3
收藏
得分:0 
都有个C嘛

XAplus!
讨论群:51090447
删吧删吧,把我的号给删了!
2007-05-25 10:25
CrazyWeed0907
Rank: 2
等 级:新手上路
威 望:5
帖 子:1385
专家分:0
注 册:2006-5-30
收藏
得分:0 
Circle c(a,b,c); 这个问题,换成别的

“十步杀一人,千里不留行。事了拂衣去,深藏身与名。”
2007-05-25 14:52
haopeng123
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2007-5-12
收藏
得分:0 

果真如此!谢谢楼上的!
不知道是什么原因呢?

2007-05-29 11:13
快速回复:不知道这个程序为什么交不上去
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011727 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved