const Coordinate *p=&coor改成const Coordinate *p;p=&coor;可以通过
#include <iostream>
using namespace std;
class Coordinate
{
public:
Coordinate(int x, int y)
{
m_iX=x;
m_iY=y;
}
public:
int m_iX;
int m_iY;
};
int main()
{
Coordinate *p=new Coordinate(1,2);
cout <<"("<<p->m_iX<<"," <<p->m_iY<<")"<< endl;
delete p;
p=NULL;
return 0;
}
using namespace std;
class Coordinate
{
public:
Coordinate(int x, int y)
{
m_iX=x;
m_iY=y;
}
public:
int m_iX;
int m_iY;
};
int main()
{
Coordinate *p=new Coordinate(1,2);
cout <<"("<<p->m_iX<<"," <<p->m_iY<<")"<< endl;
delete p;
p=NULL;
return 0;
}