请问从堆中实例化,输出结果错误怎么改
#include <iostream>
using namespace std;
class Coordinate
{
public:
Coordinate()
{
}
// 打印坐标的函数
void printInfo()
{
cout<<"("<<m_iX<<","<<m_iY<<")"<<endl;
}
public:
int m_iX;
int m_iY;
};
int main(void)
{
//定义对象数组
Coordinate *coorArr=new Coordinate[2];
coorArr->m_iX=1;
coorArr->m_iY=2;
coorArr++;
coorArr->m_iX=3;
coorArr->m_iY=4;
//遍历数组,打印对象信息
for(int i = 0; i < 2; i++)
{
coorArr[i].printInfo();
coorArr--;
}
coorArr++;
delete []coorArr;
coorArr=NULL;
return 0;
}