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 Crusable   Members   -  Reputation: 592

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.

"C spilled his beer all over C++'s shirt. Outraged, C++ shouted, "Good god, man! Have you no class?"

"Your mother is so fat that the recursive function that was used to calculate her mass created a stack overflow"

 

 


Sponsor:

#2 fastcall22   Crossbones+   -  Reputation: 4293

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: 592

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.

"C spilled his beer all over C++'s shirt. Outraged, C++ shouted, "Good god, man! Have you no class?"

"Your mother is so fat that the recursive function that was used to calculate her mass created a stack overflow"

 

 


#4 SiCrane   Moderators   -  Reputation: 9575

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: 592

Like
0Likes
Like

Posted 29 November 2012 - 07:37 AM

I fixed it so its okay

"C spilled his beer all over C++'s shirt. Outraged, C++ shouted, "Good god, man! Have you no class?"

"Your mother is so fat that the recursive function that was used to calculate her mass created a stack overflow"

 

 





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