How do header and implementation files work in C++?
<p>I have a question about the relationship between header and implementation files in C++.</p>

<p>I have received two empty header files and one empty implementation file. When I say "empty" I mean that the files only contain method declarations; I have to implement the code inside each method. (I thought that posting the code for the three files would be redundant, since they only contain declarations..)</p>

<p>The three files are:</p>

<ul>
<li><code>interface_complexmutex.h</code></li>
<li><code>complexmutex.h</code></li>
<li><code>complexmutex.cpp</code></li>
</ul>

<p><code>interface_complexmutex.h</code> has <strong>virtual</strong> methods for <code>complexmutex</code>. Also, the <code>complexmutex</code> class inherits from <code>interface_complexmutex</code>.</p>

<p>These files have basic mutex functions that I have to implement. I have 2 questions:</p>

<ol>
<li><p>Why do I need <code>interface_complexmutex.h</code>? It does not really have a <code>.cpp</code> file, and the entire implementation will be in <code>complexmutex</code> files, right?</p></li>
<li><p>How should I <strong>include</strong> these files and use <code>complexmutex</code> class in a program? (if I have the <code>init()</code> method in <code>complexmutex.cpp</code>, for example)</p>

<p>Should <code>main.cpp</code> look like this?</p>

<pre><code>#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include "interface_complexmutex.h"
#include "complexmutex.h"
using namespace std;
int main(){

    complexmutex a;

    /* do something with mutex to test */

    return 0;
}
</code></pre>

<p>I made my own Makefile, and the code above seems to run fine so far. </p></li>
</ol>
