这个输出为什么不正确
// cpptest.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
class Point
{
private:
int _x;
int _y;
public:
Point():_x(0),_y(0)
{}
int getX()
{
return _x;
}
int getY()
{
return _y;
}
void setX(int x)
{
_x = x;
}
void setY(int y)
{
_y = y;
}
void printPoint()
{
cout<<"x:" + _x <<endl;
cout<<"y:" + _y <<endl;
}
};
void setDefaultPoint(Point p,int x,int y)
{
p.setX(x);
p.setY(y);
}
void setDefaultPoint(Point& p,int x,int y,bool)
{
p.setX(x);
p.setY(y);
}
int _tmain(int argc, _TCHAR* argv[])
{
Point p;
Point* p1 = new Point();
setDefaultPoint(*p1,1,1,true);
p1->printPoint();
return 0;
}
==============
输出结果是
:
:
砸回事儿呢?
谢谢