类里面的几个point搞不清楚!
类ArrayOfPoints中的Points \Point的含义搞不清楚,导致程序出错,会VC的进来看看!希望提到各位的指点,!
#include<iostream>
using namespace std;
class Point
{
public:
Point() {X=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() {return X;}
int GetY() {return Y;}
void Move(int x,int y) { X=x;Y=y;}
private:
int X,Y;
};
class ArrayOfPoints
{
public:
ArrayOfPoints( int n) { numberOfPoints=n; Points=new Points[n];}
~ArrayOfPoints()
{
cout<< "Deleting...." << endl;
numberOfPoint=0;
delete [] Points;
}
Point& Element(int n)
{
return Points[n];
}
private:
Point *Points;
int numberOfPoints;
};
int main()
{
int number;
cout << "Please enter the number of Points:";
cin>>number;
ArrayOfPoints Points(number);
Points.Element(0).Move(3,6);
Points.Element(1).Move(6,13);
return 0;
}