C++ 6“;错误LNK2019:未解析的外部符号;

C++ 6“;错误LNK2019:未解析的外部符号;,c++,linker-errors,game-engine,sfml,unresolved-external,C++,Linker Errors,Game Engine,Sfml,Unresolved External,我有6个未解决的外部问题。我知道这意味着什么,但我不知道如何修复它 碰撞.cpp #include "Collision.h" void Collision::Collide(Entity &entity1, Entity &entity2) { if(entity1.getX() + entity1.getWidth() > entity2.getX() || entity1.getX() < entity2.getX() + entity

我有6个未解决的外部问题。我知道这意味着什么,但我不知道如何修复它

碰撞.cpp

#include "Collision.h"

void Collision::Collide(Entity &entity1, Entity &entity2)
{
    if(entity1.getX() + entity1.getWidth() > entity2.getX() ||
        entity1.getX() < entity2.getX() + entity2.getWidth() ||
        entity1.getY() + entity1.getHeight() > entity2.getY() ||
        entity1.getY() < entity2.getY() + entity2.getHeight())
    {
        entity1.setX(entity1.getX());
        entity1.setY(entity1.getY());

    }
}
其中称为碰撞

collision.Collide(player, enemy);
实体.h

#ifndef Entity_H
#define Entity_H

#include<SFML/Graphics.hpp>
#include"Animation.h"
#include"Camera.h"

class Entity
{
    public:

        void Initialize();
        void LoadContent();
        void Update(sf::RenderWindow &Window);
        void Draw(sf::RenderWindow &window);
        void setX(float newX);
        void setY(float newY);
        int getHeight();
        int getWidth();
        float getX();
        float getY();
    private:
        Camera camera;
        float x, y;
        int currentFrameX, currentFrameY;
        sf::Clock clock;
};

#endif // Entity_H

Me认为玩家/敌人类中的实体getX()等没有正确重载是个问题。

结果是
Entity.cpp
没有包含在我的项目中


谢谢克里斯和西蒙斯

看起来像是
实体。cpp
链接不正确。您是如何编译的?Entity.cpp是否包含在您的项目中?您是否费心为每个成员函数提供实现?是的,你们都是对的,事实并非如此。我现在修好了。非常感谢你!
#ifndef Entity_H
#define Entity_H

#include<SFML/Graphics.hpp>
#include"Animation.h"
#include"Camera.h"

class Entity
{
    public:

        void Initialize();
        void LoadContent();
        void Update(sf::RenderWindow &Window);
        void Draw(sf::RenderWindow &window);
        void setX(float newX);
        void setY(float newY);
        int getHeight();
        int getWidth();
        float getX();
        float getY();
    private:
        Camera camera;
        float x, y;
        int currentFrameX, currentFrameY;
        sf::Clock clock;
};

#endif // Entity_H
1>Collision.obj : error LNK2019: unresolved external symbol "public: void __thiscall Entity::setX(float)" (?setX@Entity@@QAEXM@Z) referenced in function "public: void __thiscall Collision::Collide(class Entity &,class Entity &)" (?Collide@Collision@@QAEXAAVEntity@@0@Z)
1>Collision.obj : error LNK2019: unresolved external symbol "public: void __thiscall Entity::setY(float)" (?setY@Entity@@QAEXM@Z) referenced in function "public: void __thiscall Collision::Collide(class Entity &,class Entity &)" (?Collide@Collision@@QAEXAAVEntity@@0@Z)
1>Collision.obj : error LNK2019: unresolved external symbol "public: int __thiscall Entity::getHeight(void)" (?getHeight@Entity@@QAEHXZ) referenced in function "public: void __thiscall Collision::Collide(class Entity &,class Entity &)" (?Collide@Collision@@QAEXAAVEntity@@0@Z)
1>Collision.obj : error LNK2019: unresolved external symbol "public: int __thiscall Entity::getWidth(void)" (?getWidth@Entity@@QAEHXZ) referenced in function "public: void __thiscall Collision::Collide(class Entity &,class Entity &)" (?Collide@Collision@@QAEXAAVEntity@@0@Z)
1>Collision.obj : error LNK2019: unresolved external symbol "public: float __thiscall Entity::getX(void)" (?getX@Entity@@QAEMXZ) referenced in function "public: void __thiscall Collision::Collide(class Entity &,class Entity &)" (?Collide@Collision@@QAEXAAVEntity@@0@Z)
1>Collision.obj : error LNK2019: unresolved external symbol "public: float __thiscall Entity::getY(void)" (?getY@Entity@@QAEMXZ) referenced in function "public: void __thiscall Collision::Collide(class Entity &,class Entity &)" (?Collide@Collision@@QAEXAAVEntity@@0@Z)