2 ms·
A C++ header file is much more than just serving as an interface to an implementation. Sure it can be used in that way, but it doesn't have to. Have you checke
by kccqzy 8y ago
A C++ header file is much more than just serving as an interface to an implementation. Sure it can be used in that way, but it doesn't have to.
Have you checked out the standard library's header files? If you do, you'll see they are full of templates, and constexpr functions. In some sense, the header file is where most of the code is.
Have you also checked out the concept of a single-header dependency? Due to the myriad different ways to manage dependencies, those dependencies that consist of just a header file is extremely convenient to have. This is the logical conclusion when you can put increasingly complicated things in header files.