我还是 C++ 的新手,我似乎无法在其他地方找到确切的答案。我正在尝试在构造函数中初始化一个需要 2 个浮点数的 Box 对象。Box 是从 Game Object 派生的。
我试过 Box *box = new Box(20,20);
class GameObject {
public:
GameObject::GameObject(float Posx, float Posy) {
posx = Posx;
posy = Posy;
};
protected: //Positions
float posx;
float posy;
virtual void setPosition(float x, float y) { posx = x; posy = y;};
};
class Box : GameObject { // Box is Derived from GameObject
public:
float sizex;
float sizey;
void setSize(float x, float y) {sizex = x; sizey = y;};
};