0

I'm trying to follow the Zombie Arena project in Beginning C++ Game Programming by John Horton. However, Pickup.h is giving me problems.

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();

};

When I try to compile the program, I get an illegal qualified name in member declaration error from Pickup::Pickup(int type). What could be wrong? I've tried to debug this with no success. Please help. I'm already compiling in C++ 17.

Vlad from Moscow
  • 301,070
  • 26
  • 186
  • 335
Joel Seng
  • 1
  • 1
  • 4

1 Answers1

2

Instead of this declaration of the constructor

Pickup::Pickup(int type);

write

Pickup(int type);

The qualified name of the constructor declaration is not correct though as far as I know some compilers like MS VS allow such declarations.

You may use a qualified name of a member function in its definition outside the class definition.

Vlad from Moscow
  • 301,070
  • 26
  • 186
  • 335