标签:实例 iostream class include [] 为什么 for bsp nat
#include<iostream> #include"Coordinate.h" using namespace std; int main() { coor[0].m_iY=5; // cout<<"栈中实例化"<<endl<<coor[0].m_iX<<" "<<coor[0].m_iY<<endl; Coordinate *p=new Coordinate[3]; Coordinate *k=p; p->m_iX=7; p[0].m_iY=9; // cout<<"堆中实例化"<<endl<<p[0].m_iX<<" "<<p[0].m_iY; p++; p->m_iX=11; p[1].m_iX=15; (++p)->m_iY=17; for(int i=0;i<3;i++) { cout<<"栈中实例化"<<i<<":"<<endl<<coor[i].m_iX<<" "<<coor[i].m_iY<<endl; } for(int j=0;j<3;j++) { cout<<"堆中实例化"<<j<<":"<<endl<<p->m_iX<<" "<<p->m_iY<<endl; p--; } delete []k;//这里为什么要用k,因为此时的p已经不是原来的p,指向的地址也 不是刚刚定义的地址,不可以删除!!!!!!! k=NULL; } ~
标签:实例 iostream class include [] 为什么 for bsp nat
原文地址:http://www.cnblogs.com/cxy931980808/p/6646947.html