65,211
社区成员
发帖
与我相关
我的任务
分享class Point2d
{
public:
float _x;
float _y;
};
class Point3d : public Point2d
{
public:
Point3d(float x=0.0f, float y=0.0f, float z=0.0f)
: _x(x), _y(y), _z(z)
/*
报以下错
error C2614: 'Point3d' : illegal member initialization: '_y' is not a base or member
error C2614: 'Point3d' : illegal member initialization: '_x' is not a base or member
问题一:
_x和_y是继承的成员,为什么不能初始化?
*/
{
}
float _z;
};
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}#include <iostream>
class Point2d
{
public:
Point2d(float x, float y) : _x(x), _y(y)
{
}
float _x;
float _y;
};
class Point3d : public Point2d
{
public:
Point3d(float x = 0.0f, float y = 0.0f, float z = 0.0f)
: Point2d(x, y), _z(z)
/*
报以下错
error C2614: 'Point3d' : illegal member initialization: '_y' is not a base or member
error C2614: 'Point3d' : illegal member initialization: '_x' is not a base or member
问题一:
_x和_y是继承的成员,为什么不能初始化?
*/
{
}
float _z;
};
int main(int argc, char* argv[])
{
return 0;
}