构造函数的定义
class Point{
public:
Point(int xx=0,int yy=0) //这里的构造函数有参数,下面的x和y赋值是不是就多余了?
{
x = xx;
y = yy;
}
.........
private:
int x,y;
};
程序代码:class Point
{
public:
Point() : x_(0), y_(0)
{
}
Point( int x, int y ) : x_(x), y_(y)
{
}
private:
int x_, y_;
};