How to connect to ActorComponent Character through #include?

How to connect to ActorComponent Character through #include?
Once connected, there is a lot of mistakes!

Hello. I have my character named “ThirdPersonCharacter” and ActorComponent named “HealthStats”. I’m trying to connect “HealthStats” in my character through #include “HealthStats.cpp”, but I get a lot of errors:
Severity Code Description Project File status bar suppression
Error LNK2005 “public: __cdecl UHealthStats :: UHealthStats (void)” (?? 0UHealthStats @@ QEAA @ XZ) єtsh yuyaЁhfhyhe t HealthStats.cpp.obj ThirdPerson D: \ UE4_Projects \ ThirdPerson \ Intermediate \ ProjectFiles \ ThirdPersonCharacter.cpp.obj 1
Error LNK2005 “public: virtual void __cdecl UHealthStats :: BeginPlay (void)” (? BeginPlay @ UHealthStats @@ UEAAXXZ) єtsh yuyaЁhfhyhe t HealthStats.cpp.obj ThirdPerson D: \ UE4_Projects \ ThirdPerson \ Intermediate \ ProjectFiles \ ThirdPersonCharacter.cpp.obj 1
Error LNK2005 “public: virtual void __cdecl UHealthStats :: TickComponent (float, enum ELevelTick, struct FActorComponentTickFunction *)” (TickComponent @ UHealthStats @@ UEAAXMW4ELevelTick @@ PEAUFActorComponentTickFunction @@@ Z?) Єtsh yuyaЁhfhyhe t HealthStats.cpp.obj ThirdPerson D: \ UE4_Projects \ ThirdPerson \ Intermediate \ projectFiles \ ThirdPersonCharacter.cpp.obj 1
Error LNK1169 yuserЁєtshe eyuuyuЁrЄeyu yuyaЁhfhyhee√sch ёshtyuy - yufshe shysh syuyhh ThirdPerson D: \ UE4_Projects \ ThirdPerson \ Binaries \ Win64 \ UE4Editor-ThirdPerson-6195.dll 1
Error Failed to produce item: D: \ UE4_Projects \ ThirdPerson \ Binaries \ Win64 \ UE4Editor-ThirdPerson-6195.dll ThirdPerson D: \ UE4_Projects \ ThirdPerson \ Intermediate \ ProjectFiles \ ERROR 1
Error MSB3075 Exit command “” C: \ Program Files (x86) \ Epic Games \ 4.13 \ Engine \ Build \ BatchFiles \ Build.bat “ThirdPersonEditor Win64 Development” D: \ UE4_Projects \ ThirdPerson \ ThirdPerson.uproject “-waitmutex” with code 5. Ensure that you have sufficient privileges to perform this command. ThirdPerson C: \ Program Files (x86) \ MSBuild \ Microsoft.Cpp \ v4.0 \ V140 \ Microsoft.MakeFile.Targets 41

You’ll need to provide more information to get any answer on this. The #include exposes the UActorComponent object to your ACharacter, if that’s what you’re asking. Other than that, I have no clue what your question is even about.

What errors are you getting? What are you trying to do?

Those aren’t problems with the #include, they just don’t show up until you’ve added the include because not having context for the compiler overrides other errors.

It looks like you’ve created some function definitions in the UHealthStats header file (.h) but haven’t defined them in the source file (.cpp); so the compiler is looking for those functions but can’t find them and throws the errors.

The UHealthStats::UHealthStats function is your constructor, and I think you need to include it even if it’s empty.

BeginPlay and TickComponent can be omitted if you don’t have overriding functionality for them.

Including the contents of your .h and .cpp files will help me provide more detail if needed.