#include<iostream>
#include<iomanip>
using namespace std;
class point
{
public:
void set();//设置原点坐标;;
void move();//移动距离;
void l(int x,int y);//移动后坐标及两点间距离;
int getx();
int gety();
private:
int x,y;
};
class line
{
public:
line(point a,point b);
void xl();//直线的斜率;
private:
point p1,p2;
};
main()
{
class point a,b;
class line l1(point a,point b);
cout<<"请设置直线上两点坐标:";
a.set();
b.set();
l1(a,b);
}
void point::set()
{
cin>>x;
cin>>y;
cout<<"点坐标为:("<<x<<","<<y<<")"<<endl;
}
void point::move()
{
int m,n;
cin>>m;
cin>>n;
x=x+m;
y=y+n;
cout<<"移动后坐标为:("<<x<<","<<y<<")."<<endl;
cout<<"两点间距离为:"<<sqrt(m*m+n*n)<<endl;
}
int point::getx()
{
return x;
}
int point::gety()
{
return y;
}
line::line(point a,point b):p1(a),p2(b)
{
double k;
int m,n,p,q;
p1=a;
p2=b;
m=p1.getx();
n=p1.gety();
p=p2.getx();
q=p2.gety();
k=(n-q)/(m-p);
cout<<"直线的斜率为:"<<k<<endl;
}
组建错误:
unresolved external symbol "class line __cdecl l1(class point,class point)" (?l1@@YA?AVline@@Vpoint@@0@Z)
在main中你的
class line l1(point a,point b);
定义为函数,它没有实现
当然最简单的解决方案(没细究你程序的功能)
在程序的任何位置(任何函数的外面(
写
class line l1(point a,point b)
{
///你要做的,也可以什么都不做
}
一周热门 更多>