Why does C++ have header files and .cpp files?

Why does C++ have header files and .cpp files?

Attached: 1510458385280.png (657x539, 110K)

So you don't need
if __name__ == '__main__'

Attached: 1511692894806.png (703x911, 19K)

I don't know. It's redundant boilerplate code.

Why would I need that?

In header files you declare functions, data types, classes and things like that. In .cpp files you write the implementation of said functions.

Same reason C has them. Next!

They want to introduce modules in C++20.

Unless it's a template or inline definition, because lolologic

Because you need to declare a name before you use it, but you can only define it once (One Definition Rule), otherwise the linker shits itself. Declare in header which can be included a million times, define in cpp.

Atawism from times when processing power was precious and scanning a file for identifiers would take a lot of time and memory.

A solution is to hand make a file that has the declarations and export it around.

Somehow I feel like the modules will be complete shit and worse than dealing with header files.

why not just do it in the cpp file?

This is to mainly separate the interface (the classes and functions open to use for the general user) and the implementation (the code behind the functions and classes).

They didn't learn from C mistakes.

Pretty sure the interface could be generated automatically from the implementation. Doing that manually is archaic.

>Pretty sure the interface could be generated automatically from the implementation.
This and lots of other possibilities. Even back then. Creating an OS and a programming language was just an afterthought to K&R for creating
>muh bipes

Actually it has only preprocessed text files and translation units.

Attached: Еби_Чугун.jpg (341x356, 43K)

That would remove the ability for the programmer to dictate the order of the class members in memory. It would also remove the ability of the programmer to dictate alignment size.

Nobody forces you to use them.

So that you can organize your function definitions in whatever order you want and present a clean interface into your program

Forward declaration but for all code