qq_就此别过_0
2015-08-02 15:09
#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;
}
程序是如何运行的呢
已经解决了
for(int i=0;i<3;i++)
{
cout<<"coor.x"<<coor[i].m_iX<<endl;
} cout<<"coor.y"<<coor[i].m_iY<<endl; //这行写到括号外面了,写到里面就对了
C++远征之封装篇(下)
70915 学习 · 514 问题