33,311
社区成员
发帖
与我相关
我的任务
分享
class reg : public Point {
public: //增加修饰符public
void initreg(float x, float y, float w, float h);
float getw()const;
float geth()const;
private:
float w, h;
};
Error2:函数参数默认值只可以定义一次
class Point
{
private:
float x, y;
public:
Point() {}
void initpoint(float x = 0, float y = 0);
void move(float offx, float offy);
float getX()const;
float getY()const;
};
void Point::initpoint(float x, float y ) //去除这里的默认值
{
this->x = x;
this->y = y;
}
Error3:未实现point的无参构造函数
class Point
{
private:
float x, y;
public:
Point() {} //如果你不想构造函数做任何事情,可以这样写
void initpoint(float x = 0, float y = 0);
void move(float offx, float offy);
float getX()const;
float getY()const;
};