我的代码没问题啊,为什么老是运行结果会是最下面那两行呢?
#include<iostream>
using namespace std;
class Coordinate
{
friend void display(Coordinate &coor);
public:
Coordinate(int x, int y)
{
x = m_iX;
y = m_iY;
}
private:
int m_iX;
int m_iY;
};
void display(Coordinate &coor)
{
cout << "m_iX:"<< coor.m_iX << endl;
cout << "m_iY:"<< coor.m_iY << endl;
}
int main(void)
{
Coordinate coor(7, 9);
display(coor);
return 0;
}
m_iX:-858993460
m_iY:-858993460
请按任意键继续. . .