我正在尝试跟随僵尸竞技场的项目,开始约翰霍顿的C++游戏编程。然而,Pickup.h给我带来了问题。
class Pickup
{
private:
//Start value for health pickups
const int HEALTH_START_VALUE = 50;
const int AMMO_START_VALUE = 12;
const int START_WAIT_TIME = 10;
const int START_SECONDS_TO_LIVE = 5;
// The sprite that represents this pickup
Sprite m_Sprite;
// The arena it exists in
IntRect m_Arena;
// How much is this pickup worth?
int m_Value;
// What type of pickup is this?
// 1 = health, 2 = ammo
int m_Type;
// Handle spawning and disappearing
bool m_Spawned;
float m_SecondsSinceSpawn;
float m_SecondsSinceDeSpawn;
float m_SecondsToLive;
float m_SecondsToWait;
// Public prototypes go here
public:
Pickup::Pickup(int type);
// Prepare a new pickup
void setArena(IntRect arena);
void spawn();
// Check the position of a pickup
FloatRect getPosition();
// Get the sprite for drawing
Sprite getSprite();
// Let the pickup update itself each frame
void update(float elapsedTime);
// Is this pickup currently spawned?
bool isSpawned();
// Get the goodness from the pickup
int gotIt();
// Upgrade the value of each pickup
void upgrade();
};当我试图编译程序时,我在Pickup::Pickup(int type)的成员声明错误中得到了一个非法的限定名。会出什么问题呢?我试过调试它,但没有成功。请帮帮忙。我已经在用C++ 17编译了。
发布于 2021-05-18 14:17:54
而不是构造函数的这个声明
Pickup::Pickup(int type);写
Pickup(int type);构造函数声明的限定名是不正确的,尽管据我所知,像MS VS这样的编译器允许这样的声明。
可以在类定义之外的成员函数定义中使用成员函数的限定名。
https://stackoverflow.com/questions/67580854
复制相似问题