C++ Blueprint Function Library - Private Access Error

I’m really new to programming with UE4 and C++ in combination with blueprints.
I try to create a simple Blueprint Function Library in C++ with one function “GetHappyMessage”.
I compiled all, the C++ function is listed in a Blueprint Function List in the editor, i can use it, but it fails compiling because it says its a private method and it cannot called outside of the class.
So, i have no idea to fix this. If i create the BFL directly in the editor it works as expected.
I work with 4.6.1

Here my code:

### .h file
#pragma once
#include "Kismet/BlueprintFunctionLibrary.h"
#include "GlobalFunctions.generated.h"
class TDMN_API UGlobalFunctions : public UBlueprintFunctionLibrary
	UFUNCTION(BlueprintCallable, Category = "GlobalFunctions")
	static void GetHappyMessage();		

### .cpp file
#include "TDMN.h"
#include "GlobalFunctions.h"
//Happy Message
void UGlobalFunctions::GetHappyMessage()

In a blueprint

Awesome, i feel really dumb right now :slight_smile: Never touched c++ until today… Anyway, thx for the superfast answer.

add "public: " after GENERATED_BODY() to put GetHappy in proper space.

Access modifier explanations.

GENERATED_BODY() macro actually added public for you before as a nicety. If you run into older examples… Or so I’ve read, before my time.

Don’t you worry, in general everything is declared private.

As best practice:

If you feel something should be private use private:, if public, public: and protected, protected:

Even though private is standard, always write it out for better readability.

And if you want to learn a bit more @Rama made a fantastic Entry Wiki Article

I think that was still when we used GENERATED_UCLASS_BODY(). Documentation up to 4.5 does mention it so I guess that changed in 4.6

Thx, in general i know some other programming languages but in all that i’ve used before, all was public per default :slight_smile: Also i was confused about the “static” keyword, i guessed that this already make the function static public available. I miss just the basics of c++ programming.