Home

Kai-Uwe Bux wrote:
> James Kanze wrote:
>
>> On Sep 29, 7:10 pm, yanlinli...@gmail.com wrote:
>>> I'd like to write all code of a class in only header file.
>> Why? The header file is visible by all users; the more you put
>> in it, the more coupling you get, and the harder it is to
>> maintain the program.
>
> There may be thousands of good reasons to separate header files from
> implementation files, but that one, I do not consider convincing.
>
This time, I agree with James.

> A header is meant for the compiler only. Users refer to the documentation.
> They have no business looking at the header. There is no coupling coming
> from this (unless users prefer to rely on undocumented features, which is
> entirely their problem).
>
Maybe, but headers have a strange way of finding themselves included in
compilation units, the "lower level" the header, the more places both
directly and indirectly it gets included. If there is code in the
header and the project is under development, that code is likely to get
changed, which results in all those compilation units being recompiled.

> Likewise: you don't get coupling from the standard headers should they be
> readable on a particular implementation. Why would you from another header?
>
You don't change your standard headers.

--
Ian Collins.

previous
next

cannot run test program while cross compiling.
Re: Adventure-Engines in Python
Re: inline constructor and destructor
Re: The least used keywords in C++, which do you use?
Re: ANN: SCF released GPL
Krwinka
Mam Marzenie
Nasze Dzieci
Fundacja Avalon
Podaruj Zycie