3 ms·
>It was a mistake how C++, Java and other languages forgot to split interface declaration from implementation definition Huh? C++ is split into header files (i
by meindnoch 3y ago
>It was a mistake how C++, Java and other languages forgot to split interface declaration from implementation definition
Huh? C++ is split into header files (interface) and cpp files (implementation)...
- sk0g 3y agoI guess there is no "strict separation" in C++, since that mechanism is, I believe, optional. Adding implementations to your header files might never pass PRs, but still. It does enable header-only libraries though.
- creata 3y agoBut there's no .cpp file for many (most?) uses of templates.
- meindnoch 3y agoIf you think about what templates are, it's not hard to understand why they must go completely in the header files. It's literally a source code template. It's a set of instructions to generate code at compile time, depending on the template parameters, hence 100% of the source code must be available at the point of instantiation. Just the interface is not enough.
- creata 3y agoOf course, but it still breaks the split between interface and implementation that people are talking about here.