A quick header file intro

Header files contain declarations (i.e. FString HiddenWord) which tell whatever file it’s included in (i.e. #include “BullCowCartridge.h”) what to use. The file looks at it and says “oh, HiddenWord is an FString. I’ll define it as cake”. Another file which has #include “BullCowCartridge.h” could then say “oh, HiddenWord is an FString. I’ll define it as chair” As the lessons get more complicated, there will be multiple header files used in one file (there’s header files for input/output, math functions, meshes, shapes, etc…) so that all of those functions don’t have to be rewritten everytime (and making a colossal mess of code). Another way to think of header files would be indexes of sorts. The files say I don’t know what a std::cout is, but the iostream header will tell me.

9 Likes

hi Kim , as i am new guy towards coding, do you mind explaining and labelling this line of code to me as i am confused which is considered a function/variable/declarations

FString HiddenWord = TEXT(“Cake”);

Moreover , whats a class and instance in UE4 if you have any idea about it , thank you for the time to answer this too

Hi lim_zijian, so I am new to to c++ as well but this is how I understand it:
HiddenWord has already been initialized in the header file as a string variable (Unreal requires the syntax FString to be used).
We are declaring this string to be “Cake” in this line of code (again UE4 requires TEXT() to be used in order to work properly).
So essentially all we are doing is giving the variable HiddenWord a value, which is “Cake”.

1 Like

Wow, this was an absolutely amazing and necessary explanation. Thank you! :smiley:

Privacy & Terms