Results 1 to 5 of 5

Thread: Static member assignment

  1. #1

    Thread Starter
    Addicted Member NOMADMAN's Avatar
    Join Date
    Aug 2002
    Location
    Closer than you think
    Posts
    237

    Static member assignment

    Can I assign a value to a static public memeber in a class?

    NOMAD

  2. #2
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    396
    Code:
    MyClass::MyStaticMember = 2; //Assuming MyStaticMember is a integer

  3. #3

    Thread Starter
    Addicted Member NOMADMAN's Avatar
    Join Date
    Aug 2002
    Location
    Closer than you think
    Posts
    237
    Do I need to have an instance of my class declared? I tried that and I'm getting linker errors in MSVC++ 6 saying unresolved symbol

  4. #4
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Maybe I'm missing something, but what's the point in using a static member if you don't plan to instantize your class?
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  5. #5

    Thread Starter
    Addicted Member NOMADMAN's Avatar
    Join Date
    Aug 2002
    Location
    Closer than you think
    Posts
    237
    I wanted to use initialize it by my main program. Then use it with the class function (reather the constructer). I know that sounds pretty dangerous but as long as I document thats how it works I think it should be alright.

    NOMAD

    PS I made them public static int seems to work great.

    Thanks everyone!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width