Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Imho, generating the headers from the source is a bad idea and is unpractical.</p> <p>Headers can contain more information that just function names and parameters.</p> <p>Here are some examples:</p> <ul> <li>a <code>C++</code> header can define an <em>abstract</em> class for which a source file may be unneeded</li> <li>A template can only be defined in a header file</li> <li>Default parameters are only specified in the class definition (thus in the header file)</li> </ul> <p>You usually write your header, then write the implementation in a corresponding source file.</p> <p>I think doing the other way around is counter-intuitive and doesn't fit with the spirit of <code>C</code> or <code>C++</code>.</p> <p>The only exception is can see to that is the <strong>static</strong> functions. A static function only appears in its source file (<code>.c</code>or <code>.cpp</code>) and can't (obviously) be used elsewhere.</p> <p>While I agree it is often annoying to copy the header definition of a method/function to the source file, you can probably configure your code editor to ease this. I use Vim and a quick script helped me with this <strong>a lot</strong>. I guess a similar solution exists for most other editors.</p> <p>Anyway, while this can seem annoying, keep in mind it also gives a greater flexibility. You can distribute your header files (<code>.h</code>, <code>.hpp</code> or whatever) and then transparently change the implementation in source files afterward.</p> <p>Also, just to mention it, there is no such thing as <code>C/C++</code>: there is <code>C</code> and there is <code>C++</code>; those are different languages (which indeed share much, but still).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload