#include <iostream>
#include <stdio.h>
#include "Coordinate.h"
/*********************************************************/
/*对象数组
要求:
定义Coordinate类
数据成员:m_iX和m_iY
分别从栈和堆中实例化长度为3的对象数组
给数组中的元素分别赋值
遍历两个数组
*/
/*********************************************************/
using namespace std;
int main(void)
{
Coordinate coor[3];
coor[0].m_iX = 1;
coor[0].m_iY = 2;
coor[1].m_iX = 3;
coor[1].m_iY = 4;
coor[2].m_iX = 5;
coor[2].m_iY = 6;
Coordinate *coor1 = new Coordinate[3];
coor1 -> m_iX = 11;
coor1 -> m_iY = 12;
(coor1 + 1) -> m_iX = 13;
(coor1 + 1) -> m_iY = 14;
(coor1 + 2) -> m_iX = 15;
(coor1 + 2) -> m_iY = 16;
for (int i = 0; i < 3; i++)
{
cout << coor[i].m_iX << endl;
cout << coor[i].m_iY << endl;
}
for (int j = 0; j < 3; j++)
{
cout << (coor1 + j)-> m_iX << endl;
cout << (coor1 + j)-> m_iY << endl;
}
delete[] coor1;
coor1 = NULL;
system("pause");
return 0;
}