Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>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)...



I 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.


But there's no .cpp file for many (most?) uses of templates.


If 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.


Of course, but it still breaks the split between interface and implementation that people are talking about here.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: