Jump to content

  • Log In with Google      Sign In   
  • Create Account

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   Members   

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.


#2   Moderators   

9752
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.
zlib: eJzVVLsSAiEQ6/1qCwoK i7PxA/2S2zMOZljYB1TO ZG7OhUtiduH9egZQCJH9 KcJyo4Wq9t0/RXkKmjx+ cgU4FIMWHhKCU+o/Nx2R LEPgQWLtnfcErbiEl0u4 0UrMghhZewgYcptoEF42 YMj+Z1kg+bVvqxhyo17h nUf+h4b2W4bR4XO01TJ7 qFNzA7jjbxyL71Avh6Tv odnFk4hnxxAf4w6496Kd OgH7/RxC

#3   Members   

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   Moderators   

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

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.