C++ how to create a class with a function in it

Cant get simle C++ function to work in UE4 blueprint.

I am trying to make a C++ function that will sort an array inside blueprint. The problem is i can’t get C++ and UE work together. I need a C++ class that is workable as an example. Can someone point me in the right direction or tell me what am i doing wrong?


#pragma once
#include "Object.h"
#include "FromUobject.generated.h"

class ANDROID_API UFromUobject : public UObject

UFUNCTION(BlueprintCallable, Category = "Damage")
void calcA();


    #include "Android.h"
       #include "FromUobject.h"

 void FromUobject::calcA{}

What am i missing here? how do i get it to work? Please HelP!

Your class name is actually UFromUobject, not FromUobject, and you need the arguments, even though it’s empty. So the line

void FromUobject::calcA{}

should be

void UFromUobject::calcA(){}

anything else? should i include something else in the header?

Generally you’ll want to include your project’s header file. However, the boilerplate code the editor generates should take care of that for you. How are you creating these source files? If you create a new C++ class from the editor (file menu or the content browser) that sort of stuff will just be taken care of for you.

I am creating classes from UE editor, extending some of the basic C++ classes.
The thing is that after creating some C++ classes, i lose ability to launch project on android device.
Thanks you for your answer, it got me started. Going to dive further.