#include<iostream>
#include<string>
using namespace std;
class Coordinate
{
public:
void printX();
void printY();
int x,y;
};
void Coordinate:: printY()
{cout<<y<<endl;}
void Coordinate:: printX()
{cout<<x<<endl;}
int main(void)
{
Coordinate *coor1=new Coordinate();
coor1->x=0;
coor1->y=20;
coor1->printX();
coor1->printY();
delete coor1;
coor1=NULL;
Coordinate *coor2=new Coordinate[5];
for(int i=0;i<5;i++)
{coor2[i].x=0;
coor2[i].y=20;
coor2[i].printX();
coor2[i].printY();
}
delete []coor2;
coor2=NULL;
system("pause");
}
望远
相关分类