我的运行结果(下图)和老师的运行结果(上图)不一样是什么原因?我用的编译器是visual c++6.0 下面有代码
#include "iostream"
#include"stdlib.h"
#include "string "
using namespace std ;
class coordinate
{
public:
coordinate();
~coordinate();
public:
int m_iX;
int m_iY;
};
coordinate::coordinate()
{
cout<<"coordiante"<<endl;
}
coordinate::~coordinate()
{
cout<<"~coordinate"<<endl;
}
int main()
{
coordinate coor[3];
coor[0].m_iX=3;
coor[0].m_iY=5;
coordinate * P=new coordinate[3];
P->m_iX=7;
P[0].m_iY=9;
P++;
P->m_iX=11;
P[0].m_iY=13;
P[1].m_iX=15;
P++;
P->m_iY=17;
for(int i=0;i<3;i++)
{
cout<<"coor.x"<<coor[i].m_iX<<endl;
} cout<<"coor.y"<<coor[i].m_iY<<endl;
for(int j=0;j<3;j++)
{
cout<<"p_x"<<P->m_iX<<endl;
cout<<"p_y"<<P->m_iY<<endl;
P--;
}
P++;
delete []P;
P=NULL;
system("pause");
return 0;
}