#include <iostream>using namespace std;class Coordinate{ public: Coordinate(int _x,int _y); ~Coordinate(); int getX(); int getY(); private: int x,y; };class Line{ public: Line(int x1,int y1,int x2,int y2); ~Line(); void printLine(); private: Coordinate *A; Coordinate *B;};Coordinate::Coordinate(int _x,int _y){ cout << "正在执行 点类 构造函数... "; x = _x; y = _y; cout << "(" << x << "," << y << ")" << endl; }Coordinate::~Coordinate(){ cout << "正在执行点类析构函数..." << endl; }int Coordinate::getX(){ return x;}int Coordinate::getY(){ return y;}Line::Line(int x1,int y1,int x2,int y2){ cout << "正在执行 线类 构造函数..." << endl; A = new Coordinate (x1,y1); B = new Coordinate (x2,y2);}Line::~Line(){ cout << "正在执行线类析构函数..." << endl; delete A; A = NULL; delete B; B = NULL;}void Line::printLine(){ cout << "线类信息打印... "; cout << "(" << A->getX() << "," << A->getY() << ") "; cout << "(" << B->getX() << "," << B->getY() << ")" << endl;} int main (void){ Line *line = new Line (1,2,3,4); line->printLine(); cout << "line对象的大小为: " << sizeof(line) << endl; cout << "Line类型的大小为: " << sizeof(Line) << endl; delete line; line = NULL;}