C ++'Vector':'struct'类型重新定义,对此进行了所有尝试,但仍收到相同的错误

因此,即时通讯使用sdl2库制作游戏,但我创建的简单结构会导致较大的错误。我已经看到很多人们在使用rerdefinition时遇到的错误,但是我尝试过的所有方法都失败了,我也不知道为什么。我承认对C ++还是陌生的,但我在整个堆栈中进行了搜索,并尝试了所有建议的内容,但对我来说没有任何作用。到目前为止,还没有达到图形部分,也没有太大希望。

头文件包含以下代码:

#pragma once
#ifndef PLAYER_H_
#define PLAYER_H_

struct Vector
{
    float x, y;
};

class Player
{
    Vector position;
    int health;
    int ammoCount;
    int score;
    bool lifeState;

public:
    Player();
    ~Player();
    Player(Vector pos, int hp, int ammo, int scoreboard, bool alive);
    void update();

    static const int MAX_HEALTH = 100;
    static const int MIN_HEALTH = 0;

    int getHealth();
    void increaseHealth(int increment);
    void decreaseHealth(int decrement);
};

#endif

源文件:

#include "pch.h"
#include "Player.h"


Player::Player()
{
}

Player::Player(Vector pos, int hp, int ammo, int scoreboard, bool alive)
{
    this->position = pos;
    this->health = hp;
    this->ammoCount = ammo;
    this->score = scoreboard;
    this->lifeState = alive;

}


Player::~Player()
{
}

void Player::update()
{

}

int Player::getHealth()
{
    return health;
}

void Player::increaseHealth(int increment)
{
    health += increment;

    if (health > MAX_HEALTH)
        health = MAX_HEALTH;
}

void Player::decreaseHealth(int decrement)
{
    health -= decrement;

    if (health < MIN_HEALTH)
        health = MIN_HEALTH;
}
评论