fatal error C1071: unexpected end of file found in comment到底咋回事嘛
#include<iostream>#include<cmath>usingnamespacestd;classline{public:line();line(float...
#include<iostream>
#include<cmath>
using namespace std;
class line
{
public:
line();
line(float x1,float y1,float x2,float y2);
void display();
~line();
private:
float k,a,b,c;
int k1;
};
line::line()
{
k1=1;k=0;b=0;c=0;
cout<<"executing constructor..."<<endl;
}
line::line( float x1,float y1,float x2,float y2)
{
k1=0;k=0;b=0;c=0;
if(x1==x2)c=x1;
if(y1==y2){k1=1;k=0;b=y1;}
if((x1!=x2) && (y1!=y2))
{
k1=1;k=(y2-y1)/*(x2-x1);b=y1-k*x1;c=(-1)*k/b;
}
}
void line::display()
{if(k==0)
{
cout<<"直线的斜率k不存在。"<<endl;
cout<<"直线的方程为:x="<<c<<endl;
}
if(k==0)
{
cout<<"直线的斜率k=0。"<<endl;
cout<<"直线的方程为:y="<<b<<endl;
}
if(k1==1 && k!=0)
{
cout<<"直线的斜率k="<<k<<endl;
cout<<"直线的方程为:y=<<k<<"x+"<<b<<endl;
}
line :: ~line()
{
cout<<"executing destructor...";
}
void main()
{
line l1;
l1.display();
line l2(1,1,2,2);
l2.display();
} 展开
#include<cmath>
using namespace std;
class line
{
public:
line();
line(float x1,float y1,float x2,float y2);
void display();
~line();
private:
float k,a,b,c;
int k1;
};
line::line()
{
k1=1;k=0;b=0;c=0;
cout<<"executing constructor..."<<endl;
}
line::line( float x1,float y1,float x2,float y2)
{
k1=0;k=0;b=0;c=0;
if(x1==x2)c=x1;
if(y1==y2){k1=1;k=0;b=y1;}
if((x1!=x2) && (y1!=y2))
{
k1=1;k=(y2-y1)/*(x2-x1);b=y1-k*x1;c=(-1)*k/b;
}
}
void line::display()
{if(k==0)
{
cout<<"直线的斜率k不存在。"<<endl;
cout<<"直线的方程为:x="<<c<<endl;
}
if(k==0)
{
cout<<"直线的斜率k=0。"<<endl;
cout<<"直线的方程为:y="<<b<<endl;
}
if(k1==1 && k!=0)
{
cout<<"直线的斜率k="<<k<<endl;
cout<<"直线的方程为:y=<<k<<"x+"<<b<<endl;
}
line :: ~line()
{
cout<<"executing destructor...";
}
void main()
{
line l1;
l1.display();
line l2(1,1,2,2);
l2.display();
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询