Unreal Engine C++ Developer #1

This is the course notes

UnrealCourse_Notes

Lecture Notes on Unreal Engine C++ Developer #1

1.What is include?

#include is nothing else but just copy and paste what is inside to here. It is a sort of analogy to using in C#(not entirely). You can specify which library you are using with #include

The static library and "official" libraries, let's say, are using <> . While the latter "" focusing on header file or libraries we built casually.

 

2.What is header file?

A little bit similar to interface in C#? Normally, we will declare the name and return type in header file just like in interface.

Following is a file called FBullCowGame.h

Just like we define the function in interface, header file does something similar.

Then we complement the function in FBullCowGame.cpp

Therefore, that's what I mentioned header file is just about copy and paste? In FBullCowGame.cpp, the code in FBullCowGame.h was copied and pasted here.

 

3.What is #prama once?

It literally means runs once.

 

4.Avoid using using namespace in header file even in .cpp files

using namespace is different from using xxx in C#. It literally means take a namespace from the included library. The simple case is the std library.

Not recommend:

✔️Recommend:

With your programming system growing, the using could be really to debug.

 

5.What is std::getline()?

It is a function taking user's input while it is different from std::cin.

std::getline() takes whatever user typed as a string.

If the user type Norman Foster, then the value of name is Norman Foster.

std::cin takes only one word.

If the user type Norman Foster, then the value of name is Norman. The Foster will be left in the memory and it will continue to feed the next string.

 

6.What is constexpr and const?

The naming of constexpr and const is very confusing in C++. I have a trick to remember these 2 guys.

constexpr literally means constant you want to define which can hardly be changed. Like PI:

const literally means read-only. Since there is no such concept of Property in C++ like in C#. Therefore you cannot define a read-only property like in C#:

C++ has a more complicated way of doing that:

The const ban any assignment operation or value modification operation inside the function!

 

7.Shortcut for QuickActions and Refactoring - Ctrl + .

This is very very very handy!! Highly recommend! The shortcut is Ctrl + . For example, you want to auto generate the function you declare in the .h . You can double click the function name and Ctrl + . Then Visual Studio IDE will automatically generate the block of code for you.

8.Shortcut to Rename some variable or function - Ctrl+R

Double click the variable or function, Ctrl+R

 

 

 

 

 

 


C++

Book: Beginning C++ Through Game Programming

Website: https://www.learncpp.com/

Unreal Coding Standard: https://docs.unrealengine.com/4.26/en-US/ProductionPipelines/DevelopmentSetup/CodingStandard/

 

 

Previous
Previous

VR# What's Real About Virtual Reality?

Next
Next

C++ Primer #02 Variables and Basic Types