Code outside functions

You can't write code outside of functions. The only things you can have outside of functions are declarations such as global variable declarations (usually a bad idea), function declarations etc. Try putting it in a function like int main(){}


Functions organize code so that the instruction pointer can reach the code and execute it.

If the compiler would allow you to write code outside of any function it would never run.

Put the code in a function body.

C++ does allow one case where the code itself is written outside the function body, which is a macro declaration, but the macro must be used in a function body to ever run.