class Dot{
public:
Dot(int a,int b);
~Dot();
int getX();
int getY();
void setX(int setx);
void setY(int sety);
private:
int x;
int y;
};
#include "Dot.h"
class line{
public:
line(int x1, int y1, int x2, int y2);
~line();
void setA(int a, int b);
void setB(int a, int b);
void printinfo();
private:
Dot d1;
Dot d2;
};
#include "Dot.h"
#include <iostream>
using namespace std;
Dot::Dot(int a, int b) :x(a), y(b)
{
cout << "Dot::Dot() " <<x<<" "<<y <<endl;
}
Dot::~Dot(){
cout << "Dot::~Dot()" << x << " " << y << endl;
}
int Dot::getX(){
return x;
}
int Dot::getY(){
return y;
}
void Dot::setX(int setx){
x = setx;
}
void Dot::setY(int sety){
y = sety;
}
#include "line.h"
#include "iostream"
using namespace std;
line::line(int x1, int y1, int x2, int y2):d1(x1,y1),d2(x2,y2){
cout << "line"<<endl;
}
line::~line(){
cout << "~line()" << endl;
}
void line::setA(int a, int b){
d1.setX(a) ;
d1.setY(b) ;
}
void line::setB(int a, int b){
d2.setX(a) ;
d2.setY(b);
}
void line::printinfo(){
cout << "点D1 " << d1.getX() << d1.getY();
cout << "点D2 " << d2.getX() << d2.getY();
}