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

各位大哥大姐帮个忙啊!
这个程序在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-24 09:31
zkkpkk
Rank: 2
等 级:论坛游民
威 望:5
帖 子:489
专家分:28
注 册:2006-6-17
收藏
得分:0 
既然在VC过了,你就理直气壮地埋怨学校的系统呗```

[此贴子已经被作者于2007-5-26 15:26:53编辑过]



Viva,espana!
2007-05-24 09:43
yuyunliuhen
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:1435
专家分:0
注 册:2005-12-12
收藏
得分:0 
你们学校的交题系统用的是内核是GUNC++吧,标准不同而已。

[此贴子已经被作者于2007-5-24 12:51:03编辑过]



Go confidently in the  directions of your dreams,live the life you have imagined!Just do it!
It is no use learning without thinking!
2007-05-24 12:33
haopeng123
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2007-5-12
收藏
得分:0 
应该是吧,莫名其妙的.
2007-05-26 09:52
快速回复:不知道这个程序为什么交不上去
数据加载中...
 
   



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

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