| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 475 人关注过本帖
标题:请教,麻烦一下大家
只看楼主 加入收藏
coming10
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-6-17
收藏
 问题点数:0 回复次数:0 
请教,麻烦一下大家

#include<iostream.h>
#include<math.h>
#define PI 3.1415
class CBase
{public:
virtual float area(){return 0.0;}
protected:
float a;
CBase(float x){a=x;}
};

class Tria:public CBase
{protected:
float b;float c;
public:
Tria(float x,float y,float z):CBase(x)
{b=y;c=z;}
float area()
{float l=(a+b+c)/2;
return sqrt(l*(l-a)*(l-b)*(l-c)); }
};

class Square:public CBase
{protected:
float area()
{return a*a;}
};

class Round:public CBase
{protected:
float area()
{return PI*a*a;}
};
void print(CBase &p)
{cout<<p.area()<<endl;}
void main()
{
Tria e(3.3f,5.2f,8f);
cout<<"三角形的面积为:\t";
print(a);
Square f(6.0f);
cout<<"正方形的面积为:\t";
print(f);
Round g(1.5f);
cout<<"圆形的面积为:\t";
print(g);

}

--------------------Configuration: S1 - Win32 Debug--------------------
Compiling...
1.cpp
C:\Documents and Settings\KING\桌面\新建文件夹\S1\1.cpp(20) : warning C4244: 'return' : conversion from 'double' to 'float', possible loss of data
C:\Documents and Settings\KING\桌面\新建文件夹\S1\1.cpp(32) : warning C4244: 'return' : conversion from 'double' to 'float', possible loss of data
C:\Documents and Settings\KING\桌面\新建文件夹\S1\1.cpp(38) : error C2059: syntax error : 'bad suffix on number'
C:\Documents and Settings\KING\桌面\新建文件夹\S1\1.cpp(38) : error C2146: syntax error : missing ')' before identifier 'f'
C:\Documents and Settings\KING\桌面\新建文件夹\S1\1.cpp(38) : error C2059: syntax error : ')'
C:\Documents and Settings\KING\桌面\新建文件夹\S1\1.cpp(40) : error C2065: 'a' : undeclared identifier
C:\Documents and Settings\KING\桌面\新建文件夹\S1\1.cpp(41) : error C2664: 'Square::Square' : cannot convert parameter 1 from 'const float' to 'const class Square &'
Reason: cannot convert from 'const float' to 'const class Square'
No constructor could take the source type, or constructor overload resolution was ambiguous
C:\Documents and Settings\KING\桌面\新建文件夹\S1\1.cpp(44) : error C2664: 'Round::Round' : cannot convert parameter 1 from 'const float' to 'const class Round &'
Reason: cannot convert from 'const float' to 'const class Round'
No constructor could take the source type, or constructor overload resolution was ambiguous
执行 cl.exe 时出错.


主函数之前的程序都没有错误,但是编完主函数就这样叻,请教一下怎么改正?

搜索更多相关主题的帖子: 麻烦 
2007-06-17 10:43
快速回复:请教,麻烦一下大家
数据加载中...
 
   



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

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