#include <iostream>
#include <cassert>
using namespace std;
class Point {
public://外部接口
Point() :x(0), y(0) {
cout << "Default Constructor called" << endl;
}
Point(int x, int y) : x(x), y(y) {//构造函数
cout << "Constructor called" << endl;
}
~Point() { cout << "Destructor called" << endl; }
void move(int newX, int newY) {
x = newX;
y = newY;
}
int getX() const { return x; }//const 表示该函数不修改任何值;
int getY() const { return y; }
static int count;//静态数据成员声明,用于记录点的个数
static void showCount() {
cout << " Object count= " << count << endl;
}
private:
int x, y;
};
//动态数组类
class ArrayOfPoints {
public:
ArrayOfPoints(int size) :size(size) {
points = new Point[size];
}
~ArrayOfPoints() {
cout << "Deleting ...";
delete[] points;
}
//获取下标为index的数据元素
Point& element(int index) {
assert(index