主题:各位大虾帮忙看一下代码为什么里面这个实现不了!!!!求助
#include <iostream.h>
class Line
{
public:
Line(float a=0,float b=0)
{
xishua=a;
xishub=b;
}
void print()
{
cout<<"y="<<xishua<<"x+"<<xishub<<endl;
}
friend float setPoint(Line &,Line &);
void Point(float x,float y)
{
heng=x;
zong=y;
cout<<"x="<<heng<<endl;
cout<<"y="<<zong<<endl;
}
private:
float xishua;
float xishub;
float heng;
float zong;
};
float setPoint(Line &l1,Line &l2)//求两直线的交点
{
float x,y;
x=(l2.xishub-l1.xishub)/(l1.xishua-l2.xishub);
y=l1.xishua*x+l1.xishub;
return (x,y);
}
void main()
{
Line l1(2,1);
Line l2(3,2);
setPoint(l1,l2);
l1.print();
l2.print();
}
各位大虾
问题请教啊,
我是想通过那个友元函数求出两条直线的交点,然后将交点的值放到之前定义的那个void Point(float x,float y)这个函数中,然后输出这个点的坐标,可是我这样写的代码为什么都不能实现啊,我不是很清楚要怎样才能将求交点的函数中求出来的值送到那个void Point(float x,float y)函数中......
求助求助!!!!
万分感谢!!!!
class Line
{
public:
Line(float a=0,float b=0)
{
xishua=a;
xishub=b;
}
void print()
{
cout<<"y="<<xishua<<"x+"<<xishub<<endl;
}
friend float setPoint(Line &,Line &);
void Point(float x,float y)
{
heng=x;
zong=y;
cout<<"x="<<heng<<endl;
cout<<"y="<<zong<<endl;
}
private:
float xishua;
float xishub;
float heng;
float zong;
};
float setPoint(Line &l1,Line &l2)//求两直线的交点
{
float x,y;
x=(l2.xishub-l1.xishub)/(l1.xishua-l2.xishub);
y=l1.xishua*x+l1.xishub;
return (x,y);
}
void main()
{
Line l1(2,1);
Line l2(3,2);
setPoint(l1,l2);
l1.print();
l2.print();
}
各位大虾
问题请教啊,
我是想通过那个友元函数求出两条直线的交点,然后将交点的值放到之前定义的那个void Point(float x,float y)这个函数中,然后输出这个点的坐标,可是我这样写的代码为什么都不能实现啊,我不是很清楚要怎样才能将求交点的函数中求出来的值送到那个void Point(float x,float y)函数中......
求助求助!!!!
万分感谢!!!!