没搞懂整个运行顺序
没搞懂整个运行顺序
没搞懂整个运行顺序
2019-10-31
#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[2]; //coorArr是Coordinate类的对象
coorArr[0].m_iX = 1; //对象的数据成员
coorArr[0].m_iY = 2;
coorArr[1].m_iX = 3;
coorArr[1].m_iY = 4;
//遍历数组,打印对象信息
for(int i = 0; i < 2; i++)
{
coorArr[i].printInfo();
}
return 0;
}
举报