Is it possible in c++ to forbid calling a certain function at compile time?
<p>I have 2 classes:</p>

<pre><code>class Entity {
   void addChild(Entity* e);
};

class Control : public Entity {

};
</code></pre>

<p>What I want to do is to not allow adding a Control as a child of something that's not a Control. So, for example:</p>

<pre><code>Control c;
Entity e;
e.addChild(c); // This line would throw an error (at compile time if possible);
</code></pre>

<p>The first thing I thought of is adding this to Entity:</p>

<pre><code>void addChild(Control* c){
    assert(false);
};
</code></pre>

<p>NOTE: both Entity and Control are abstract classes but both has many subclasses.   </p>

<p>But is there any way to get an error at compile time?</p>
