Cant create class object?

Started by
1 comment, last by DejaimeNeto 10 years, 2 months ago

So i have a class:


class Sprite
{...};

and im trying to make an object of that class called mrSquare in another class:


private:

	Sprite *mrSquare;

but i get an error, "syntax error : missing ';' before identifier 'mrSquare", as if its not recognizing 'Sprite' as a class type? I typed this code from some other tutorials im doing for practice and everything seems to be okay, including the header file and everything where im attempting to create the class...is there something im doing wrong?

Advertisement
You may have a circular inclusion problem. Try reading this article, paying attention to problem number 2.

Since the compiler is accusing a syntax error, it would be better if you could show us more code. The declaration of the second class would probably be enough, but the full code of the file would be better. (pastebin it if too big.)

Also, make sure to include your "header including section" for both files (as they are probably declared in two different files). This way we can see if we have a circular dependency or similar problem (that would result in weird syntax error reports).

This topic is closed to new replies.

Advertisement