Local function definitions are illegal?

When trying to build i get this error:

C:\Users\Joe\Documents\Unreal Projects\FPSProject\Source\FPSProject\FPSGameMode.cpp(11): error C2601: ‘AFPSGameMode::StartPlay’ : local function definitions are illegal

I am reading from This Tutorial and have not differed from it at all, however i cannot complete the build, what does it mean by local function definitions are illegal?

FPSGameMode.cpp:

#include "FPSProject.h"
#include "FPSGameMode.h"


AFPSGameMode::AFPSGameMode(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
	void AFPSGameMode::StartPlay()
	{
		Super::BeginPlay();

		if (GEngine)
		{
			GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("HELLO WORLD"));
		}
	}
	
}

Hurdurrr. You can’t define a function inside another function, i.e I was trying to define StartPlay() inside of main(). Moving it outside fixed the problems.

I am a noob noob noob

Yeah, i had a little mental blank, for a second. Anyway thanks for the quick answer i’ll give you the points :slight_smile:

Like the error said, you can’t implement a class function inside a class function. They’ll have to be seperate, like below:

 #include "FPSProject.h"
 #include "FPSGameMode.h"
 
 AFPSGameMode::AFPSGameMode(const class FPostConstructInitializeProperties& PCIP)
     : Super(PCIP)
 {
     
 }

 void AFPSGameMode::StartPlay()
 {
     Super::BeginPlay();

     if (GEngine)
     {
         GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("HELLO WORLD"));
     }
 }