Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy am I getting error C2061 (syntax error: identifier)?
    text
    copied!<p>Okay... I've been wrestling this error for at least an hour now. I have my StaticSprite class inherit from my Component class. However, when I try to instantiate a StaticSprite instance, I get error c2016.</p> <p>Here's my relevant code, I'll post more if need be. Thanks in advance.</p> <h3>StaticSprite.h</h3> <pre><code>#ifndef STATICSPRITE_H_ #define STATICSPRITE_H_ #include "Component.h" #include &lt;SFML/Graphics.hpp&gt; #include &lt;string&gt; namespace GE { class Entity; class Component; class StaticSprite : public Component { private: sf::Image image; public: sf::Sprite Sprite; StaticSprite(); StaticSprite(std::string filename); }; } #endif </code></pre> <h3>Component.h</h3> <pre><code>#ifndef COMPONENT_H_ #define COMPONENT_H_ #include "Entity.h" #include "ComponentType.h" #include &lt;iostream&gt; namespace GE { class Entity; class Component { protected: Entity* myEntity; TYPE type; public: Component(); virtual ~Component() {} Entity* getEntity(); }; } #endif </code></pre> <h3>main.cpp</h3> <pre><code>int main(int argc, char* argv[]) { Entity Player; //The first arg is just a number, and the second is the //actual component to add to the Entity's component array Player.addComponent(StaticSprite, new StaticSprite()); //error //application loop } </code></pre> <h3>Entity.cpp</h3> <pre><code>//TYPE is just an enumerated type void Entity::addComponent(TYPE type, void* component) { Components[type] = component; } </code></pre> <h3>ComponentType.h</h3> <pre><code>#ifndef COMPONENTTYPE_H_ #define COMPONENTTYPE_H_ namespace GE { enum TYPE{Base = 0, StaticSprite, DynamicSprite, Physics, Collision, Input, Particle, Audio, Scriptable, MaxType}; } #endif </code></pre>
 

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