Your class should deriver from AActor or UObject. Also it should include some generated headers and so on.
It’s kind a boring task to explain every aspect here, so the best solution for you should be making new class from Unreal Editor:
- Start Unreal Editor.
- In Content Browser open C++ Classes.
- Choose folder you want your newly created class to be in.
- Right click on free space and choose “New C++ Class…”
- In a Choose Parent Class window click on checkbox in right top corner called “Show All Classes”
- Type “UObject” in search field to be sure you are right. Or just:
- Select Object in search results and click Next button.
- Name your class and check desired location.
As a result, you’ll get already compiled, correctly written class.
Like this one:
MyNewObject.h:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "Object.h"
#include "MyNewObject.generated.h"
/**
*
*/
UCLASS()
class MYGAME_API UMyNewObject : public UObject
{
GENERATED_BODY()
};
MyNewObject.cpp:
// Fill out your copyright notice in the Description page of Project Settings.
#include "MyGame.h"
#include "MyNewObject.h"