Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

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 alt text

Product Version: Not Selected
more ▼

asked Feb 13 '15 at 06:42 PM in C++ Programming

avatar image

51 5 7 10

avatar image ngrts Feb 13 '15 at 06:50 PM

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

Access modifier explanations.

avatar image User-313834801 Feb 13 '15 at 06:53 PM

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

avatar image Martin Egger Feb 13 '15 at 07:03 PM

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


avatar image User-313834801 Feb 13 '15 at 07:12 PM

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.

avatar image ngrts Feb 13 '15 at 07:07 PM

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.

avatar image Martin Egger Feb 13 '15 at 07:11 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question