#include <iostream>#include<stdlib.h>using namespace std;class Coordinate{ public: Coordinate(){} Coordinate(int x, int y) { // 设置X,Y的坐标 m_iX=x; m_iY=y; }public: int m_iX; int m_iY; };int main(void){ // 在堆上创建对象指针 Coordinate *p=new Coordinate(); Coordinate(3,4); // 打印坐标 cout <<"("<<p->m_iX<<"," <<p->m_iY<<")"<< endl; // 销毁对象指针 delete []p; p=NULL; system("pause"); return 0;}
1 回答
- 1 回答
- 0 关注
- 1417 浏览
添加回答
举报
0/150
提交
取消