Thursday, August 23, 2007

Coordinate system display. and other Calculations on it

#include
#include
using namespace std;
class point
{
protected:
float x,y;

public:
void setpoint(float x1,float y1)
{
x=x1;
y=y1;
}
void showpoint()
{
cout<<"x coodinate="< }
point getpoint()
{
point t;
t.x=x;
t.y=y;

return t;
}
float getx()
{
return x;
}
float gety()
{
return y;
}
};
#include
using namespace std;
class expoint:public point
{
private:
float x,y;
expoint()
{
x=getx();
y=gety();
}

float distance(expoint p1)
{
float d;
d=sqrt(pow(((x)-(p1.x)),2)+pow(((y)-(p1.y)),2));
return d;
}
point section(expoint p1,int n,int d)
{
point m;
m.x=(n*p1.x+d*x)/(n+d);
m.y=(n*p1.y+d*y)/(n+d);
return m;
}






};
int main()
{
point a,b,c;
a.setpoint(4,4);
a.showpoint();
expoint a1(a);
float l;
b.setpoint(4,4);
b.showpoint();
l=a1.distance(b);
cout< c=a1.section(b,1,1);
c.showpoint();
return 0;
}

No comments: