第一次写类 不知道哪里错了
不知道哪里错了\\triangle.h
class triangle
{
private:
float a,b,c;
public:
void Setlength(float lengthA,float lengthB,float lengthC);
void Judgetype();
void Circumference();
void area();
};
\\triangle.cpp
#include <iostream.h>
#include "triangle.h"
void triangle::Setlength (float lengthA,float lengthB,float lengthC)
{ float a,b,c;
a=lengthA;b=lengthB;c=lengthC;
}
void triangle::Judgetype ()
{ float t,m;
if(a>b)
t=a;a=b;b=t;
if(a>c)
t=a;a=c;c=t;
if(b>c)
t=b;b=c;c=t;
m=a+b;
if(m<=c)
cout<<"This is not a triangle."<<endl;
else
if(a=b!=c)
{
if(a*a+b*b=c*c)
cout<<"This is a Rt isosceles triangle."<<endl;
else
cout<<"This is a isosceles triangle."<<endl;
}
if(a=b=c)
{
cout<<"This is a equilateral triangle."<<endl;
}
if(a!=b&&a!=c)
{
if (a*a+b*b=c*c)
cout<<"This is a Rt triangle."<<endl;
else
cout<<"This is a common triangle."<<endl;
}
}
float triangle::Circumference ()
{
float cir;
cir=a+b+c;
cout<<"The circumference is"<<cir<<endl;
}
float triangle::area ()
{
float p,s;
p=(a+b+c)/2;
s=sqrt(p*(p-a)*(p-b)*(p-c));
cout<<"The area is"<<s<<endl;
}
\\main.cpp
#include <iostream.h>
#include "triangle.h"
void main()
{
triangle triangleA;
triangleA.Setlength();
cout<<triangleA.Circumference ()<<endl;
cout<<triangleA.area ()<<endl;
cout<<triangleA.Judgetype ()<<endl;
}