• Advertisement
Sign in to follow this  
  • entries
    68
  • comments
    57
  • views
    41991

I love finding something new

Sign in to follow this  

339 views

Was reading one of my C++ books at work today and found something that would help me a lot.. handt noticed it before but now that i have a firmer grasp on things it helps a lot to see stuff i didnt see when i knew nothing.. Its funny I was trying to think of a way to do this and it was a simple keyword lol. this is why programming is so great.. you always learn new things. well iam out to conquer more obstacales of my engine take it easy
[EDIT] haha VC++ 6.0 wont complie it

here is an example

class test_class
{
private:
static SDL_Surface* main_window; // here is the error
// the rest of my crap
};


Dunno if its VC++ 6.0 or iam not implmenting the static member right i dunno its late and i just worked all day ill get my book outa my truck in the morning..

What the book says static does is make that static member the same for all instances of the class which is great for making a min window in a video system class for SDL... but it wont compile.. ill re read teh section in the morning. night all
Sign in to follow this  


2 Comments


Recommended Comments

Static member variables must be declared and initialized:


class foo
{
private:
static int bar;
};

// in the implementation file
int foo::bar = 0;


Share this comment


Link to comment
hrm not working the way i want... lets see what i can do to fix it.. maybe i cant use it for what i wanted it lol... well got it working but i had to do it as a global couldnt do it inside my init function which deterates my class stucture ... oh well ill make a work around it hopefully

[EDIT] nm i fixed it i was being stupid thinking like a newb...

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement