# C++ Blueprint Function Library - Private Access Error

**URL:** <https://forums.unrealengine.com/t/c-blueprint-function-library-private-access-error/306872>\
**Category:** Blueprint\
**Tags:** error, function-library, unreal-engine, CPP, Blueprint, question\
**Created:** [February 13, 2015, 6:42pm UTC](https://forums.unrealengine.com/t/c-blueprint-function-library-private-access-error/306872 "2015-02-13T18:42:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![BrainFooLong](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BrainFooLong](https://forums.unrealengine.com/u/BrainFooLong)\
**Post date:** [February 13, 2015, 6:42pm UTC](https://forums.unrealengine.com/t/c-blueprint-function-library-private-access-error/306872/1 "2015-02-13T18:42:19Z")

</div>

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"
UCLASS()
class TDMN_API UGlobalFunctions : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()		
	UFUNCTION(BlueprintCallable, Category = "GlobalFunctions")
	static void GetHappyMessage();		
};

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

```

In a blueprint

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/3/6/5363d01cd3b89f6fadca7f767b0cb403ff2c0fcb.png) ](https://i.imgur.com/hwrvFQV.png)

---

<div class="post-metadata">

**Author:** ![ngrts\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ngrts\_1](https://forums.unrealengine.com/u/ngrts_1)\
**Post date:** [February 13, 2015, 6:50pm UTC](https://forums.unrealengine.com/t/c-blueprint-function-library-private-access-error/306872/2 "2015-02-13T18:50:10Z")

</div>

add "public: " after GENERATED\_BODY() to put GetHappy in proper space.

Access modifier [explanations](http://en.cppreference.com/w/cpp/language/access).

---

<div class="post-metadata">

**Author:** ![BrainFooLong](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BrainFooLong](https://forums.unrealengine.com/u/BrainFooLong)\
**Post date:** [February 13, 2015, 6:53pm UTC](https://forums.unrealengine.com/t/c-blueprint-function-library-private-access-error/306872/3 "2015-02-13T18:53:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![neryun](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/neryun/32/722041_2.png) [@neryun](https://forums.unrealengine.com/u/neryun)\
**Post date:** [February 13, 2015, 7:03pm UTC](https://forums.unrealengine.com/t/c-blueprint-function-library-private-access-error/306872/4 "2015-02-13T19:03:20Z")

</div>

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

> **[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 — ue4community.wiki! You will be able to find content from the official...

---

<div class="post-metadata">

**Author:** ![ngrts\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ngrts\_1](https://forums.unrealengine.com/u/ngrts_1)\
**Post date:** [February 13, 2015, 7:07pm UTC](https://forums.unrealengine.com/t/c-blueprint-function-library-private-access-error/306872/5 "2015-02-13T19:07:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![neryun](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/neryun/32/722041_2.png) [@neryun](https://forums.unrealengine.com/u/neryun)\
**Post date:** [February 13, 2015, 7:11pm UTC](https://forums.unrealengine.com/t/c-blueprint-function-library-private-access-error/306872/6 "2015-02-13T19:11:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![BrainFooLong](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BrainFooLong](https://forums.unrealengine.com/u/BrainFooLong)\
**Post date:** [February 13, 2015, 7:12pm UTC](https://forums.unrealengine.com/t/c-blueprint-function-library-private-access-error/306872/7 "2015-02-13T19:12:52Z")

</div>

Thx, in general i know some other programming languages but in all that i’ve used before, all was public per default 🙂 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.
