Download

Declaring class members

I have created a C++ class inheriting fom AActor (and annotated with the UCLASS() macro). Everything compiles fine, but if I add a custom member funtion (with no UE macro annotations) I get an “out-of-line declaration” error for its implementation (this is on XCode). The declaration in the cpp file is definitely correct, and I don’t have any idea what might be going wrong.
So, the header looks like



UCLASS()
class AMyActor : public AActor
{
    GENERATED_UCLASS_BODY()
  
    float GetDateNumber(int16 year, int16 month, int16 day);
};


and the implemenation



AMyActor::AMyActor(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{

}

float AMyActor::GetDateNumber(int year, int month, int day)
{
    return 1.0f;
}


Any suggestions?

You use int16 in declaration and int in implementation.

Hi, I dont use XCode but here I also have an error when I try to compile your code.

Try this


float ATestNetworkCharacter::GetDateNumber(int16 year, int16 month, int16 day)
{
	return 1.0f;
}

Replace int by int16 as your declaration. Here it solve the issue.

Doh!

Thanks guys, of course that was the problem! Actually, the method signature was created by XCode’s auto-complete, so I didn’t look hard enough at the variable types.