Jump to content

View more

Image of the Day

WIP title screen for #DeathOfAPartisan #screenshotsaturday #gamedev https://t.co/qJNhfZCvd4
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Cant create class object?

4: Adsense

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   

381
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?



#2 SiCrane   Moderators   

11765
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   Members   

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