# Error: 'Function' is not allowed before the Class definition

**URL:** <https://forums.unrealengine.com/t/error-function-is-not-allowed-before-the-class-definition/391814>\
**Category:** Blueprint\
**Tags:** unreal-engine, Blueprint, question\
**Created:** [April 24, 2017, 10:31pm UTC](https://forums.unrealengine.com/t/error-function-is-not-allowed-before-the-class-definition/391814 "2017-04-24T22:31:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_fdeb980f](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_fdeb980f](https://forums.unrealengine.com/u/anonymous_user_fdeb980f)\
**Post date:** [April 24, 2017, 10:31pm UTC](https://forums.unrealengine.com/t/error-function-is-not-allowed-before-the-class-definition/391814/1 "2017-04-24T22:31:30Z")

</div>

i am having trouble getting a pure static blueprint function to compile, this is the error i get.

```
LogCompile: /home/raptor/Documents/Unreal Projects/MyProject/Plugins/MyPlugin/Source/MyPlugin/Public/IMyPlugin.h(374): Error: 'Function' is not allowed before the Class definition
Error: 'Function' is not allowed before the Class definition

```

this is my header:

```
#include "Runtime/UMG/Public/UMG.h"
#include "Runtime/UMG/Public/UMGStyle.h"
#include "Runtime/UMG/Public/Slate/SObjectWidget.h"
#include "Runtime/UMG/Public/IUMGModule.h"
#include "Runtime/UMG/Public/Blueprint/UserWidget.h"
#include "AIController.h"
#include "Components/AudioComponent.h"
#include "AudioDecompress.h"
#include "AudioDevice.h"
#include "ActiveSound.h"
#include "Audio.h"
#include "Developer/TargetPlatform/Public/Interfaces/IAudioFormat.h"
#include "VorbisAudioInfo.h"
#include "IMyPlugin.generated.h"

class IMyPlugin : public IModuleInterface {
	IMyPlugin& Get() {
		return FModuleManager::LoadModuleChecked<IMyPlugin>("MyPlugin");
	}
	bool IsAvailable() {
		return FModuleManager::Get().IsModuleLoaded("MyPlugin");
	}
};
USTRUCT(BlueprintType)
struct FMyCustomStruct {
	GENERATED_USTRUCT_BODY()
		UPROPERTY(EditAnywhere, Category=Triangle)
		FVector Vertex0;
		UPROPERTY(EditAnywhere, Category=Triangle)
		FVector Vertex1;
		UPROPERTY(EditAnywhere, Category=Triangle)
		FVector Vertex2;
};

UCLASS(editinlinenew, meta=(BlueprintSpawnableComponent), ClassGroup=Rendering)
class UMyCustomObject: public UObject {
GENERATED_BODY()
  public:
	TArray<FMyCustomStruct> MyStructs;
	std::weak_ptr<UMyCustomObject> __weakref__ ;
	bool __initialized_UMyCustomObject;
	constexpr static const char* __class__ = "UMyCustomObject";
	virtual std::string get_class_name(){ return std::string("UMyCustomObject");}
	bool SetCustomMeshTriangles(const TArray<FMyCustomStruct>& Structs);
};
UFUNCTION(BlueprintPure,meta=(DisplayName="Hello World",CompactNodeTitle="HelloWorld",Keywords="String Hello World"))
static FText HelloWorld();

```

this is my cpp file:

```
#pragma once
#include <ModuleManager.h>
//#include <MyPluginPrivatePCH.h>
#include <IMyPlugin.h>

bool UMyCustomObject::SetCustomMeshTriangles(const TArray<FMyCustomStruct>& Structs) {		
		this->MyStructs = Structs;
		return true;
	}
FText UCreateNewObject::HelloWorld() {
	return FText::FromString("Hello World!");
}

class FMyPlugin : public IMyPlugin {
	virtual void StartupModule() override {
	std::cout << std::string("TESTING MYBLUEPRINT...") << std::endl;
}
	virtual void ShutdownModule() override {	
	std::cout << std::string("MYBLUEPRINT EXIT") << std::endl;
}
};
IMPLEMENT_MODULE( FMyPlugin, MyPlugin )

```

---

<div class="post-metadata">

**Author:** ![Jamie\_Dale](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jamie_dale/32/1165413_2.png) [@Jamie\_Dale](https://forums.unrealengine.com/u/Jamie_Dale)\
**Post date:** [April 24, 2017, 11:09pm UTC](https://forums.unrealengine.com/t/error-function-is-not-allowed-before-the-class-definition/391814/2 "2017-04-24T23:09:36Z")

</div>

A `UFUNCTION` has to be inside a `UCLASS`. Yours is declared outside any class and is later defined inside `UCreateNewObject`.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_fdeb980f](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_fdeb980f](https://forums.unrealengine.com/u/anonymous_user_fdeb980f)\
**Post date:** [April 25, 2017, 12:03am UTC](https://forums.unrealengine.com/t/error-function-is-not-allowed-before-the-class-definition/391814/3 "2017-04-25T00:03:15Z")

</div>

i was unsure about that, because following this tutorial by Rama, i didn’t see the function signature defined inside a class.

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — https://unrealcommunity.wiki/! You will be able to find content from...

---

<div class="post-metadata">

**Author:** ![Jamie\_Dale](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jamie_dale/32/1165413_2.png) [@Jamie\_Dale](https://forums.unrealengine.com/u/Jamie_Dale)\
**Post date:** [April 25, 2017, 12:25am UTC](https://forums.unrealengine.com/t/error-function-is-not-allowed-before-the-class-definition/391814/4 "2017-04-25T00:25:01Z")

</div>

Hmm, I can see how that might be misleading, but the function should be declared and defined within the same class (just like you would a normal C++ function that belongs to a class). UFunctions have to go inside a class because they need to be outered to a UObject.
