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;
coorArr--;
for(int i = 0; i < 2; i++)
{
coorArr[i].printInfo();
}
delete []coorArr;
coorArr = NULL;
return 0;
}
{
Coordinate* coorArr = new Coordinate[2];
coorArr->m_iX = 1;
coorArr->m_iY = 2;
coorArr++;
coorArr->m_iX = 3;
coorArr->m_iY = 4;
coorArr--;
for(int i = 0; i < 2; i++)
{
coorArr[i].printInfo();
}
delete []coorArr;
coorArr = NULL;
return 0;
}
int main(void)
{
Coordinate*p=new Coordinate[1];
for (int i=0;i<2;i++)
{
p->SetXY(2*i+1,2*(i+1));
p++;
}
for(int i = 0; i < 2; i++)
{
p--;
p->printInfo();
}
p++;
delete[] p;
p=NULL;
system("pause");
return 0;
}
{
Coordinate*p=new Coordinate[1];
for (int i=0;i<2;i++)
{
p->SetXY(2*i+1,2*(i+1));
p++;
}
for(int i = 0; i < 2; i++)
{
p--;
p->printInfo();
}
p++;
delete[] p;
p=NULL;
system("pause");
return 0;
}
已采纳回答 / Allxiangzi3571672
把Coordinate*p=new Coordinate[1];改成Coordinate*p=new Coordinate[3];
2016-06-15