Functions in C++

Currently going through the Unreal engine C++ course and have completed the triplex game, however one thing that sticks out to me is that when writing our own functions we have to have either; int, bool or void before the name of our function but aren’t those just data types?

For example an int can be a variable int MyVariable = 1 and is an integer yet the main function is written int main() {}, why is this? Coming from JS I would use var, let or consts for data types and then function myFunction() {} for a function. Any explanation for this would be insightful.

It would be the functions return type. Void if nothing, int if an int, etc. main returns an int after execution

Privacy & Terms