Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


OOP and SDL problems


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
4 replies to this topic

#1 Crusable   Members   -  Reputation: 594

Like
0Likes
Like

Posted 29 November 2012 - 12:03 AM

Hello, i am trying to setup a class for handling everything in my program so that the my main.cpp isn't cluttered. However i have some SDL_Surfaces that i need to use in different member functions of the class, but the program crashed when i defined them in the class and then initialize them in the constructor. So i initialize them in the class as const static SDL_Surfaces; I still got an error saying i need to have a const member to initialize them in the class. Could someone please show me a different method, or fix my method. Thanks

Edited by Mathew Bergen, 29 November 2012 - 12:05 AM.


Sponsor:

#2 fastcall22   Crossbones+   -  Reputation: 4387

Like
0Likes
Like

Posted 29 November 2012 - 12:23 AM

... but the program crashed when i defined them in the class and then initialize them in the constructor. So i initialize them in the class as const static SDL_Surfaces; I still got an error saying i need to have a const member to initialize them in the class....

Sounds to me like you're attempting to use SDL before initializing SDL.
c3RhdGljIGNoYXIgeW91cl9tb21bMVVMTCA8PCA2NF07CnNwcmludGYoeW91cl9tb20sICJpcyBmYXQiKTs=

#3 Crusable   Members   -  Reputation: 594

Like
0Likes
Like

Posted 29 November 2012 - 12:37 AM

I initialized it in my constructor, but when the SDL_Surfaces are in the constructor it cannot find them through tho rest of the class, that's why i need help, i'm not sure what to do to fix it.

#4 SiCrane   Moderators   -  Reputation: 9629

Like
0Likes
Like

Posted 29 November 2012 - 06:53 AM

If you have a compiler error you should probably post the relevant code as well as the actual compiler error.

#5 Crusable   Members   -  Reputation: 594

Like
0Likes
Like

Posted 29 November 2012 - 07:37 AM

I fixed it so its okay




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