请教VC编程问题
我的原程序。
#include <math.h>
class TTriangle
{
private:
float a,b,c;
public:
TTriangle(float x=0,float y=0,float z=0)
{
a=x;b=y;c=z;
};
void Set(float &x,float &y,float &z)
{
a=x;b=y;c=z;
};
void Get(float &x,float &y,float &z)
{
x=a;y=b;z=c;
};
friend float Area(TTriangle &);
}
float Area(TTriangle &iT)
{
float tS,tA;
tS=(iT.a+iT.b+iT.c)/2;
tA=sqrt((tS-iT.a)*(tS-iT.b)*(tS-iT.c)*tS));
}
#include <iostream.h>
void main(void)
{
TTriangle iT(3.0,4.0,5.0);
cout<<"the "<<Area(iT);
}
编译错误提示:
-------------------Configuration: 118a - Win32 Debug--------------------
Compiling...
118a.cpp
D:\test\118a.cpp(23) : error C2628: 'TTriangle' followed by 'float' is illegal (did you forget a ';'?)
D:\test\118a.cpp(24) : error C2556: 'class TTriangle __cdecl Area(class TTriangle &)' : overloaded function differs only by return type from 'float __cdecl Area(class TTriangle &)'
D:\test\118a.cpp(20) : see declaration of 'Area'
D:\test\118a.cpp(24) : error C2371: 'Area' : redefinition; different basic types
D:\test\118a.cpp(20) : see declaration of 'Area'
D:\test\118a.cpp(27) : error C2059: syntax error : ')'
D:\test\118a.cpp(27) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
Error executing cl.exe.
118a.obj - 4 error(s), 1 warning(s)
谢谢大家。