4-1对象指针
定义一个类:
class Coordinate{
public:
int m_iX;
int m_iY;
};
实例化一个对象:
Coordinate *p = new Coordinate;
`在堆区分配内存:`![](http://images2015.cnblogs.com/blog/939857/201611/939857-20161118110851107-82638650.png)
// 访问对象指针
int main(){
Coordinate *p = new Coordinate;
p->m_iX = 10; // (*p).m_iX = 10;
p->m_iY = 20; // (*p).m_iY = 20;
delete p;
p = NULL;
return 0;
}