Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>What is the point of the declaration <code>class Component;</code> if you include <code>Component.h</code>, anyway? You cannot inherited from an incomplete type, so this declaration makes no sense.</p> <p>A wild guess is circular include issues, but it's really hard to tell without more information. I recommend reading <a href="http://archive.gamedev.net/archive/reference/programming/features/orgfiles/index.html" rel="nofollow">this article</a> on <em>Organizing Code Files in C and C++</em> if you are unclear on the subject.</p> <p>Edit:</p> <blockquote> <pre><code>Player.addComponent(StaticSprite, new StaticSprite()); </code></pre> </blockquote> <p>You cannot pass the <em>type</em> <code>StaticSprite</code> to a method. That's probably the source of the error. Show us the declaration of <code>addComponent</code>. What is the first parameter type?</p> <p>Edit:</p> <blockquote> <pre><code>void Entity::addComponent(TYPE type, void* component) </code></pre> </blockquote> <p>Okay, so what is the definition of <code>TYPE</code>? I guess it's just a typedef for <code>int</code> or something? In that case it should be clear that you cannot assign the type <code>StaticSprite</code> to an <code>int</code>.</p> <p>Edit:</p> <blockquote> <pre><code>enum TYPE{Base = 0, StaticSprite, DynamicSprite, Physics, Collision, Input, Particle, Audio, Scriptable, MaxType}; </code></pre> </blockquote> <p>Yep, there you have it. The <em>enumerator</em> <code>TYPE::StaticSprite</code> has absolutely nothing to do with the <em>type</em> <code>StaticSprite</code>, even though they have the same name. Give the enumerator some other name, for example <code>T_StaticSprite</code>, and the following code should work:</p> <blockquote> <pre><code>Player.addComponent(T_StaticSprite, new StaticSprite()); </code></pre> </blockquote> <p>(Whether this whole type enumeration thing is a good idea is a different question.)</p>
 

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