Zdrojáky - objektové 5/5

#include <iostream>
#include <math.h>
using namespace std;

class Bod{
private:
double xp, yp;
public:
/*bod(){
this->xp=0;
this->yp=0;
}*/
Bod(double x=0, double y=0):xp(x),yp(y){
}
double x() const {
return xp;
}
double y() const {
return yp;
}
double x(double _xp){
return this->xp=_xp;
}
double y(double _yp){
return this->yp=_yp;
}
void print() const {
cout << "Xova: " << this->xp << endl;
cout << "Yova: " << this->yp << endl;
}
};

class Usecka{
Bod start, end;
public:
Usecka(double xk, double yk): start(), end(xk,yk){
}
Usecka(const Bod &a, const Bod &b): start(a), end(b){
}
double dlzka() const;
};

double Usecka::dlzka() const{
return sqrt((start.x()-end.x())*(start.x()-end. x())+(start.y()-end.y())*(start.y()-end. y()));
};

class Usecka_v:public Bod
{double dlz,uhol;
public:
Usecka_v():Bod(),dlz(0),uhol(0){};
Usecka_v(double x,double y,double l,double n):Bod(x,y),dlz(l),uhol(n){};
Bod Koncovy_bod();};
;};

int main(){
Bod a; //vytvori bod a[0,0]
Bod b(5,6); //b[5,6]
Usecka u(5,6); //u[0,0]->[5,6]
Usecka v(a,Bod(5,6));
cout << u.dlzka();

return 1;
}