?? 6_17.cpp
字號:
#include<iostream.h>
class Point
{ public:
Point()
{ X=Y=0; cout<<"Default Constructor called."<<endl; }
Point(int xx,int yy)
{ X=xx; Y=yy; 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;
};
int main()
{
Point *Ptr=new Point[2]; //創建對象數組
Ptr[0].Move(5,10); //通過指針訪問數組元素的成員
Ptr[1].Move(15,20); //通過指針訪問數組元素的成員
cout<<"Deleting..."<<endl;
delete []Ptr; //刪除整個對象數組
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -