//例6-17
#include <iostream>
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;
}
int getX() const { return x; }
int getY() const { return y; }
void move(int newX, int newY)
{
x = newX;
y = newY;
}
private:
int x, y;
};
void test01()
{
Point* ptr = new Point[2];
ptr[0].move(5, 10);
ptr[1].move(15, 20);
cout << "Deleting..." << endl;
delete[] ptr;
}
int main()
{
test01();
return 0;
}