[C++] unresolved externals when creating voids?

Hi! This is the wrror:

>     Creating library C:\Users\me\Documents\Unreal Projects\ProjectYpsilon\Intermediate/Build/Win64\UE4Editor\Development\UE4Editor-ProjectYpsilon-9636.lib and object C:\Users\me\Documents\Unreal Projects\ProjectYpsilon\Intermediate/Build/Win64\UE4Editor\Development\UE4Editor-ProjectYpsilon-9636.exp
24>RTSUnit.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl ARTSUnit::onSelectedUnit(void)" (?onSelectedUnit@ARTSUnit@@UEAAXXZ)
24>ProjectYpsilon.generated.cpp.obj : error LNK2019: unresolved external symbol "public: virtual void __cdecl ARTSUnit::onSelectedUnit(void)" (?onSelectedUnit@ARTSUnit@@UEAAXXZ) referenced in function "class UFunction * __cdecl Z_Construct_UFunction_ARTSUnit_onSelectedUnit(void)" (?Z_Construct_UFunction_ARTSUnit_onSelectedUnit@@YAPEAVUFunction@@XZ)
24>RTSUnit.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl ARTSUnit::onUnSelectedUnit(void)" (?onUnSelectedUnit@ARTSUnit@@UEAAXXZ)
24>ProjectYpsilon.generated.cpp.obj : error LNK2019: unresolved external symbol "public: virtual void __cdecl ARTSUnit::onUnSelectedUnit(void)" (?onUnSelectedUnit@ARTSUnit@@UEAAXXZ) referenced in function "class UFunction * __cdecl Z_Construct_UFunction_ARTSUnit_onSelectedUnit(void)" (?Z_Construct_UFunction_ARTSUnit_onSelectedUnit@@YAPEAVUFunction@@XZ)
24>RTSUnit.cpp.obj : error LNK2019: unresolved external symbol "public: void __cdecl ARTSUnit::setOwnership(short)" (?setOwnership@ARTSUnit@@QEAAXF@Z) referenced in function "public: void __cdecl ARTSUnit::execsetOwnership(struct FFrame &,void * const)" (?execsetOwnership@ARTSUnit@@QEAAXAEAUFFrame@@QEAX@Z)
24>ProjectYpsilon.generated.cpp.obj : error LNK2001: unresolved external symbol "public: void __cdecl ARTSUnit::setOwnership(short)" (?setOwnership@ARTSUnit@@QEAAXF@Z)

The error occurs when I uncomment the following in my .h file:

UFUNCTION()
		virtual void onSelectedUnit();
	UFUNCTION()
		virtual void onUnSelectedUnit();
	UFUNCTION()
		void setOwnership(int16 team);

the voids in my .cpp file:

void onSelectedUnit()
{

}

void onUnselectedUnit()
{

}

void setOwnership(int16 team)
{
	int16 myTeam = team;
}

I have tried to make sure I am declaring my functions correctly, and this seems to be how it is done, or at least how it was done in 4.2. Thanks!

Your function definitions (in the CPP file) aren’t scoped with your class name, so they’ll be functions at the global scope as far as the linker is concerned, hence the errors.

void ARTSUnit::onSelectedUnit()
 {
 
 }
 
 void ARTSUnit::onUnselectedUnit()
 {
 
 }
 
 void ARTSUnit::setOwnership(int16 team)
 {
     int16 myTeam = team;
 }

thank you so much!