Jump to content

  • Log In with Google      Sign In   
  • Create Account


Cant create class object?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Penanito   Members   -  Reputation: 180

Like
0Likes
Like

Posted 19 January 2014 - 08:35 PM

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?



Sponsor:

#2 SiCrane   Moderators   -  Reputation: 9392

Like
3Likes
Like

Posted 19 January 2014 - 08:48 PM

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

#3 dejaime   Crossbones+   -  Reputation: 3708

Like
0Likes
Like

Posted 19 January 2014 - 11:14 PM

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).


Edited by dejaime, 19 January 2014 - 11:20 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS