Programming Guide - Explaining Hello World
Okay, time to explain the Hello World code. Let me know if this is confusing, and I'll break it down a little more.
--------------------------------------------
Like how some Paradox games feel on launch (or how their launch feels looking back), C++ doesn't have much content direct content in the language. But it's easy to pull new features in using the #include instruction. Items in angle brackets <> afterwards are things in defined directories, generally official things (so, like DLC). But you can also put in items in quotes, which is like adding a mod. It'd look like this:
It's frequent you'll have a stack of these at the top of a file. Also, starting next year the particulars will change, but the fact that you need to add content to the programming language will remain.
iostream is a bunch of functionality related to inputting and outputting stuff.
--------------------------------------------
This is an example of a function. Like a Vic2 factory or a Factorio building, it takes in some stuff, does work on it, and returns some stuff.
- int - what the function outputs, in this case a number (in whole number — integer — format)
- main - the name of the function, so it can be referenced. Like Factorio constructions, you use functions to build bigger, better ones.
- () - what the function uses as inputs. In this case nothing. There will be better examples later.
- { - the beginning of the function itself
- } - the end of the function
I mentioned the name being referenced. main is a special function, one that the thing running your program references when it starts your program. So this is where everything starts running.
--------------------------------------------
Code:
std::cout << "Hello world, this is the start of a converter!";
When you ran your program, you saw most of this line, so clearly this outputs stuff. C++ uses what it calls streams for output. You use the characters << to put stuff into a stream, and that causes it to go to the right place (back to the command line, to a file, to a printer, to be stored somewhere, etc). Similarly, the characters >> can get stuff out of a stream. More on that another time.
std::cout is a special stream that outputs to the command-line. Most programming languages have an equivalent. It's useful for a short time here, but we'll be moving on from it very quickly.
And then there's the text you output. Notice it's in quotes. That tells the language that it's a bunch of text, not instructions to try to follow.
--------------------------------------------
And that's your first program explained! Ask any questions you might have, and I'll put together instructions for how to make something more exciting.